Exemplo n.º 1
0
 /**
  * @param Record $record
  *
  * @return array
  */
 protected function getReplacements(Record $record)
 {
     $replacements = [];
     foreach ($record->getContext() as $key => $val) {
         if (null === $val || is_scalar($val) || method_exists($val, '__toString')) {
             $replacements['{' . $key . '}'] = $val;
         } elseif (is_object($val)) {
             $replacements['{' . $key . '}'] = '[object ' . get_class($val) . ']';
         } else {
             $replacements['{' . $key . '}'] = '[' . gettype($val) . ']';
         }
     }
     return $replacements;
 }
Exemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function format(Record $record)
 {
     $replacements = [];
     if (false !== strpos($this->messageFormat, '%datetime%')) {
         $replacements['%datetime%'] = $this->convertToString($record->getCreatedAt());
     }
     if (false !== strpos($this->messageFormat, '%channel%')) {
         $replacements['%channel%'] = $record->getChannel();
     }
     if (false !== strpos($this->messageFormat, '%level_name%')) {
         $replacements['%level_name%'] = $record->getLevel()->getName();
     }
     if (false !== strpos($this->messageFormat, '%message%')) {
         $replacements['%message%'] = $record->getMessage();
     }
     if (false !== strpos($this->messageFormat, '%context%')) {
         $replacements['%context%'] = $this->convertToString($record->getContext(), true);
     }
     if (false !== strpos($this->messageFormat, '%extras%')) {
         $replacements['%extras%'] = $this->convertToString($record->getExtras(), true);
     }
     return strtr($this->messageFormat, $replacements);
 }
Exemplo n.º 3
0
 /**
  * @inheritdoc
  */
 protected function write(Record $record)
 {
     $this->logger->log($record->getLevel()->getName(), $record->getMessage(), $record->getContext());
 }