mirror of
https://github.com/Seldaek/monolog.git
synced 2025-07-30 18:00:17 +02:00
This commit is contained in:
committed by
Jordi Boggiano
parent
cf0f4b3814
commit
320909a1d1
@@ -186,7 +186,11 @@ class LineFormatter extends NormalizerFormatter
|
||||
{
|
||||
if ($this->allowInlineLineBreaks) {
|
||||
if (0 === strpos($str, '{')) {
|
||||
return str_replace(array('\r', '\n'), array("\r", "\n"), $str);
|
||||
$str = preg_replace('/(?<!\\\\)\\\\[rn]/', "\n", $str);
|
||||
if (null === $str) {
|
||||
$pcreErrorCode = preg_last_error();
|
||||
throw new \RuntimeException('Failed to run preg_replace: ' . $pcreErrorCode . ' / ' . Utils::pcreLastErrorMessage($pcreErrorCode));
|
||||
}
|
||||
}
|
||||
|
||||
return $str;
|
||||
|
@@ -155,6 +155,14 @@ class LineFormatterTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertRegexp('{^\['.date('Y-m-d').'] core\.CRITICAL: foobar \{"exception":"\[object] \(RuntimeException\(code: 0\): Foo at '.preg_quote(substr($path, 1, -1)).':'.(__LINE__ - 8).'\)\n\[stacktrace]\n#0}', $message);
|
||||
}
|
||||
|
||||
public function testInlineLineBreaksRespectsEscapedBackslashes()
|
||||
{
|
||||
$formatter = new LineFormatter(null, 'Y-m-d');
|
||||
$formatter->allowInlineLineBreaks();
|
||||
|
||||
self::assertSame('{"test":"foo'."\n".'bar\\\\name-with-n"}', $formatter->stringify(["test" => "foo\nbar\\name-with-n"]));
|
||||
}
|
||||
|
||||
public function testDefFormatWithExceptionAndStacktraceParserFull()
|
||||
{
|
||||
$formatter = new LineFormatter(null, 'Y-m-d');
|
||||
|
Reference in New Issue
Block a user