/** * {@inheritDoc} */ public function __invoke(LogEntryInterface $logEntry) { $context = $logEntry->getContext(); $context['memory']['used'] = memory_get_usage(true); $context['memory']['peak'] = memory_get_peak_usage(true); $logEntry->setContext($context); }
/** * {@inheritDoc} */ protected function write(LogEntryInterface $logEntry) { if ($this->stream) { flock($this->stream, LOCK_EX); fwrite($this->stream, $logEntry->getFormatted() . $this->getEol()); flock($this->stream, LOCK_UN); } }
/** * {@inheritDoc} */ protected function write(LogEntryInterface $logEntry) { $ident = $logEntry->getChannel(); if (!openlog($ident, $this->logopts, $this->facility)) { throw new LogicException(Message::get(Message::LOG_SYSLOG_FAIL, $ident, $this->facility), Message::LOG_SYSLOG_FAIL); } syslog($this->priorities[$logEntry->getLevel()], $logEntry->getFormatted()); }
/** * Replace any '{item}' in the messsage with context['item'] value * * @see http://www.php-fig.org/psr/psr-3/ * * {@inheritDoc} */ public function __invoke(LogEntryInterface $logEntry) { $message = $logEntry->getMessage(); $context = $logEntry->getContext(); $replace = []; foreach ($this->getPlaceHolders($message) as $name => $ph) { $replace[$ph] = $this->replaceWith($name, $ph, $context); } $logEntry->setMessage(strtr($message, $replace)); }
/** * Execute related handlers on the log entry * * @param LogEntryInterface $logEntry * @return $this * @access protected * @since 2.0.1 added level checking here */ protected function runHandlers(LogEntryInterface $logEntry) { // get related handlers $queue = $this->getCallables('handlers', $logEntry->getChannel()); // loop thru these handlers foreach ($queue as $data) { // stopped ? if ($logEntry->isPropagationStopped()) { break; } // run handler only if level allowed if (LogLevel::$levels[$logEntry->getLevel()] >= LogLevel::$levels[$data['extra']]) { call_user_func($data['data'], $logEntry); } } return $this; }
/** * {@inheritDoc} */ public function __invoke(LogEntryInterface $logEntry) { $context = $logEntry->getContext(); $context['uid'] = $this->uid; $logEntry->setContext($context); }
/** * {@inheritDoc} */ public function __invoke(LogEntryInterface $logEntry) { $context = $logEntry->getContext(); $context['counter'] = ++static::$counter; $logEntry->setContext($context); }
/** * {@inheritDoc} */ protected function write(LogEntryInterface $logEntry) { // record all messages static::$messages[] = $logEntry->getFormatted(); }
/** * {@inheritDoc} */ public function __invoke(LogEntryInterface $logEntry) { $logEntry->setFormatted($this->format($logEntry)); }
/** * {@inheritDoc} */ protected function write(LogEntryInterface $logEntry) { echo $logEntry->getFormatted(); }
/** * {@inheritDoc} */ protected function format(LogEntryInterface $logEntry) { $data = ['%datetime%' => date('Y-m-d H:i:s', $logEntry->getTimestamp()), '%level%' => strtoupper($logEntry->getLevel()), '%message%' => $logEntry->getMessage(), '%channel%' => $logEntry->getChannel()]; return strtr($this->format, $data); }