Sfoglia il codice sorgente

Adjust #39, only show extra/context when necessary, remove date

Jordi Boggiano 14 anni fa
parent
commit
f2abbf3f7c
1 ha cambiato i file con 12 aggiunte e 7 eliminazioni
  1. 12 7
      src/Monolog/Formatter/WildfireFormatter.php

+ 12 - 7
src/Monolog/Formatter/WildfireFormatter.php

@@ -50,6 +50,17 @@ class WildfireFormatter implements FormatterInterface
             unset($record['extra']['line']);
         }
 
+        $message = array('message' => $record['message']);
+        if ($record['context']) {
+            $message['context'] = $record['context'];
+        }
+        if ($record['extra']) {
+            $message['extra'] = $record['extra'];
+        }
+        if (count($message) === 1) {
+            $message = reset($message);
+        }
+
         // Create JSON object describing the appearance of the message in the console
         $json = json_encode(array(
             array(
@@ -58,13 +69,7 @@ class WildfireFormatter implements FormatterInterface
                 'Line'  => $line,
                 'Label' => $record['channel'],
             ),
-            array(
-                'message' => $record['message'],
-                // Use RFC1123 date format as default for js
-                'date'    => $record['datetime']->format(\DateTime::RFC1123),
-                'context' => $record['context'],
-                'extra'   => $record['extra']
-            ),
+            $message,
         ));
 
         // The message itself is a serialization of the above JSON object + it's length