1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-07-31 18:30:15 +02:00

Add context.* replacement in line formatter, fixes #717

This commit is contained in:
Jordi Boggiano
2016-03-01 16:58:06 +00:00
parent bf61d9ff3f
commit 25131bb5f6
2 changed files with 21 additions and 0 deletions

View File

@@ -91,6 +91,20 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('['.date('Y-m-d').'] meh.ERROR: log '."\n", $message);
}
public function testContextAndExtraReplacement()
{
$formatter = new LineFormatter('%context.foo% => %extra.foo%');
$message = $formatter->format(array(
'level_name' => 'ERROR',
'channel' => 'meh',
'context' => array('foo' => 'bar'),
'datetime' => new \DateTime,
'extra' => array('foo' => 'xbar'),
'message' => 'log',
));
$this->assertEquals('bar => xbar', $message);
}
public function testDefFormatWithObject()
{
$formatter = new LineFormatter(null, 'Y-m-d');