1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-12 16:14:08 +02:00

Merge pull request #388 from MacDada/LineFormatter_dont_show_empty_arrays_option

LineFormatter: context and extra optionally not shown when empty
This commit is contained in:
Jordi Boggiano
2014-07-19 21:11:34 +02:00
2 changed files with 35 additions and 4 deletions

View File

@@ -77,6 +77,20 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('['.date('Y-m-d').'] meh.ERROR: log [] test {"ip":"127.0.0.1"}'."\n", $message);
}
public function testContextAndExtraOptionallyNotShownIfEmpty()
{
$formatter = new LineFormatter(null, 'Y-m-d', false, true);
$message = $formatter->format(array(
'level_name' => 'ERROR',
'channel' => 'meh',
'context' => array(),
'datetime' => new \DateTime,
'extra' => array(),
'message' => 'log',
));
$this->assertEquals('['.date('Y-m-d').'] meh.ERROR: log '."\n", $message);
}
public function testDefFormatWithObject()
{
$formatter = new LineFormatter(null, 'Y-m-d');