mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-13 16:44:23 +02:00
Added $appendNewline flag to the JsonFormatter to enable using it when logging to files, fixes #344
This commit is contained in:
@@ -19,13 +19,16 @@ class JsonFormatterTest extends TestCase
|
||||
/**
|
||||
* @covers Monolog\Formatter\JsonFormatter::__construct
|
||||
* @covers Monolog\Formatter\JsonFormatter::getBatchMode
|
||||
* @covers Monolog\Formatter\JsonFormatter::isAppendingNewlines
|
||||
*/
|
||||
public function testConstruct()
|
||||
{
|
||||
$formatter = new JsonFormatter();
|
||||
$this->assertEquals(JsonFormatter::BATCH_MODE_JSON, $formatter->getBatchMode());
|
||||
$formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_NEWLINES);
|
||||
$this->assertEquals(true, $formatter->isAppendingNewlines());
|
||||
$formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_NEWLINES, false);
|
||||
$this->assertEquals(JsonFormatter::BATCH_MODE_NEWLINES, $formatter->getBatchMode());
|
||||
$this->assertEquals(false, $formatter->isAppendingNewlines());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,6 +38,10 @@ class JsonFormatterTest extends TestCase
|
||||
{
|
||||
$formatter = new JsonFormatter();
|
||||
$record = $this->getRecord();
|
||||
$this->assertEquals(json_encode($record)."\n", $formatter->format($record));
|
||||
|
||||
$formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_JSON, false);
|
||||
$record = $this->getRecord();
|
||||
$this->assertEquals(json_encode($record), $formatter->format($record));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user