예제 #1
0
 /**
  * @inheritdoc
  */
 public function formatMessage($message)
 {
     list($text, $level, $category, $timestamp) = $message;
     $level = Logger::getLevelName($level);
     if (!is_string($text)) {
         // exceptions may not be serializable if in the call stack somewhere is a Closure
         if ($text instanceof \Exception) {
             $text = (string) $text;
         } else {
             $text = VarDumper::export($text);
         }
     }
     $prefix = $this->getMessagePrefix($message);
     return "{$prefix}[{$level}][{$category}] {$text}";
 }
예제 #2
0
 /**
  * Formats a log message for display as a string.
  *
  * @param array $message the log message to be formatted.
  *        The message structure follows that in [[Logger::messages]].
  * @return string the formatted message
  */
 public function formatMessage($message)
 {
     list($text, $level, $category, $timestamp) = $message;
     $level = Logger::getLevelName($level);
     if (!is_string($text)) {
         // exceptions may not be serializable if in the call stack somewhere is a Closure
         if ($text instanceof \Exception) {
             $text = (string) $text;
         } else {
             $text = VarDumper::export($text);
         }
     }
     $traces = [];
     if (isset($message[4])) {
         foreach ($message[4] as $trace) {
             $traces[] = "in {$trace['file']}:{$trace['line']}";
         }
     }
     $prefix = $this->getMessagePrefix($message);
     return date('Y-m-d H:i:s', $timestamp) . " {$prefix}[{$level}][{$category}] {$text}" . (empty($traces) ? '' : "\n    " . implode("\n    ", $traces));
 }