1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-02-24 06:52:34 +01:00

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

This commit is contained in:
Jordi Boggiano 2011-08-03 18:41:13 +02:00
parent 6e589ac028
commit f2abbf3f7c

View File

@ -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