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

Strip inline line breaks from LineFormatter entries.

This commit is contained in:
Gunnar Lium
2014-02-14 12:46:14 +01:00
parent 6cabe95f23
commit 2aa09265fc
2 changed files with 45 additions and 3 deletions

View File

@@ -150,6 +150,34 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase
));
$this->assertEquals('['.date('Y-m-d').'] test.CRITICAL: bar [] []'."\n".'['.date('Y-m-d').'] log.WARNING: foo [] []'."\n", $message);
}
public function testFormatShouldStripInlineLineBreaks()
{
$formatter = new LineFormatter(null, 'Y-m-d');
$message = $formatter->format(
array(
'message' => "foo\nbar",
'context' => array(),
'extra' => array(),
)
);
$this->assertRegExp('/foo bar/', $message);
}
public function testFormatShouldNotStripInlineLineBreaksWhenFlagIsSet()
{
$formatter = new LineFormatter(null, 'Y-m-d', true);
$message = $formatter->format(
array(
'message' => "foo\nbar",
'context' => array(),
'extra' => array(),
)
);
$this->assertRegExp('/foo\nbar/', $message);
}
}
class TestFoo