예제 #1
0
 /**
  * {@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);
 }
예제 #2
0
 /**
  * {@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);
     }
 }
예제 #3
0
 /**
  * {@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());
 }
예제 #4
0
 /**
  * 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));
 }
예제 #5
0
 /**
  * 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;
 }
예제 #6
0
 /**
  * {@inheritDoc}
  */
 public function __invoke(LogEntryInterface $logEntry)
 {
     $context = $logEntry->getContext();
     $context['uid'] = $this->uid;
     $logEntry->setContext($context);
 }
예제 #7
0
 /**
  * {@inheritDoc}
  */
 public function __invoke(LogEntryInterface $logEntry)
 {
     $context = $logEntry->getContext();
     $context['counter'] = ++static::$counter;
     $logEntry->setContext($context);
 }
예제 #8
0
 /**
  * {@inheritDoc}
  */
 protected function write(LogEntryInterface $logEntry)
 {
     // record all messages
     static::$messages[] = $logEntry->getFormatted();
 }
예제 #9
0
 /**
  * {@inheritDoc}
  */
 public function __invoke(LogEntryInterface $logEntry)
 {
     $logEntry->setFormatted($this->format($logEntry));
 }
예제 #10
0
 /**
  * {@inheritDoc}
  */
 protected function write(LogEntryInterface $logEntry)
 {
     echo $logEntry->getFormatted();
 }
예제 #11
0
 /**
  * {@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);
 }