Example #1
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));
 }
Example #2
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);
 }