1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-22 09:06:10 +02:00

Add support for objects in WildfireFormatter

This commit is contained in:
Kirill chEbba Chebunin
2011-08-02 23:47:29 +04:00
parent fe0b8b59ed
commit 4c07f2dcc5
2 changed files with 13 additions and 15 deletions

View File

@@ -18,14 +18,10 @@ use Monolog\Logger;
*
* @author Eric Clemmons (@ericclemmons) <eric@uxdriven.com>
* @author Christophe Coevoet <stof@notk.org>
* @author Kirill chEbba Chebunin <iam@chebba.org>
*/
class WildfireFormatter extends LineFormatter
class WildfireFormatter implements FormatterInterface
{
/**
* Similar to LineFormatter::SIMPLE_FORMAT, except without the "[%datetime%]"
*/
const SIMPLE_FORMAT = "%message% %context% %extra%";
/**
* Translates Monolog log levels to Wildfire levels.
*/
@@ -47,16 +43,11 @@ class WildfireFormatter extends LineFormatter
$file = $line = '';
if (isset($record['extra']['file'])) {
$file = $record['extra']['file'];
unset($record['extra']['file']);
}
if (isset($record['extra']['line'])) {
$line = $record['extra']['line'];
unset($record['extra']['line']);
}
// Format record according with LineFormatter
$message = parent::format($record);
// Create JSON object describing the appearance of the message in the console
$json = json_encode(array(
array(
@@ -65,7 +56,13 @@ class WildfireFormatter extends LineFormatter
'Line' => $line,
'Label' => $record['channel'],
),
$message,
array(
'message' => $record['message'],
// Use RFC1123 date format as default for js
'date' => $record['datetime']->format(\DateTime::RFC1123),
'context' => $record['context'],
'extra' => $record['extra']
),
));
// The message itself is a serialization of the above JSON object + it's length