mirror of
https://github.com/Seldaek/monolog.git
synced 2025-07-30 01:40:30 +02:00
Use json_encode for the whole message formatting, refs #686
This commit is contained in:
@@ -70,13 +70,7 @@ class FluentdFormatter implements FormatterInterface
|
||||
$message['level_name'] = $record['level_name'];
|
||||
}
|
||||
|
||||
return '['
|
||||
. '"' . $tag . '"'
|
||||
. ', '
|
||||
. $record['datetime']->getTimestamp()
|
||||
. ', '
|
||||
. json_encode($message)
|
||||
. ']';
|
||||
return json_encode(array($tag, $record['datetime']->getTimestamp(), $message));
|
||||
}
|
||||
|
||||
public function formatBatch(array $records)
|
||||
|
@@ -40,8 +40,9 @@ class FluentdFormatterTest extends TestCase
|
||||
|
||||
$formatter = new FluentdFormatter();
|
||||
$this->assertEquals(
|
||||
'["test", 0, {"message":"test","extra":[],"level":300,"level_name":"WARNING"}]',
|
||||
$formatter->format($record));
|
||||
'["test",0,{"message":"test","extra":[],"level":300,"level_name":"WARNING"}]',
|
||||
$formatter->format($record)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,7 +55,8 @@ class FluentdFormatterTest extends TestCase
|
||||
|
||||
$formatter = new FluentdFormatter(true);
|
||||
$this->assertEquals(
|
||||
'["test.error", 0, {"message":"test","extra":[]}]',
|
||||
$formatter->format($record));
|
||||
'["test.error",0,{"message":"test","extra":[]}]',
|
||||
$formatter->format($record)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user