mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-11 23:54:04 +02:00
JsonFormatter: add option to ignore empty context
and extra
fields
Similar to efe572cb10
.
This commit is contained in:
@@ -295,4 +295,23 @@ class JsonFormatterTest extends TestCase
|
||||
$this->assertCount(1001, $res['context'][0]);
|
||||
$this->assertEquals('Over 1000 items (2000 total), aborting normalization', $res['context'][0]['...']);
|
||||
}
|
||||
|
||||
public function testEmptyContextAndExtraFieldsCanBeIgnored()
|
||||
{
|
||||
$formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_JSON, true, true);
|
||||
|
||||
$record = $formatter->format(array(
|
||||
'level' => 100,
|
||||
'level_name' => 'DEBUG',
|
||||
'channel' => 'test',
|
||||
'message' => 'Testing',
|
||||
'context' => array(),
|
||||
'extra' => array(),
|
||||
));
|
||||
|
||||
$this->assertSame(
|
||||
'{"level":100,"level_name":"DEBUG","channel":"test","message":"Testing"}'."\n",
|
||||
$record
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user