mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-10 23:24:02 +02:00
Let indexed arrays to support inline linebreaks in LineFormatter (#1818)
This commit is contained in:
@@ -192,7 +192,7 @@ class LineFormatter extends NormalizerFormatter
|
||||
protected function replaceNewlines(string $str): string
|
||||
{
|
||||
if ($this->allowInlineLineBreaks) {
|
||||
if (0 === strpos($str, '{')) {
|
||||
if (0 === strpos($str, '{') || 0 === strpos($str, '[')) {
|
||||
$str = preg_replace('/(?<!\\\\)\\\\[rn]/', "\n", $str);
|
||||
if (null === $str) {
|
||||
$pcreErrorCode = preg_last_error();
|
||||
|
@@ -147,6 +147,8 @@ class LineFormatterTest extends TestCase
|
||||
$formatter->allowInlineLineBreaks();
|
||||
|
||||
self::assertSame('{"test":"foo'."\n".'bar\\\\name-with-n"}', $formatter->stringify(["test" => "foo\nbar\\name-with-n"]));
|
||||
self::assertSame('["indexed'."\n".'arrays'."\n".'without'."\n".'key","foo'."\n".'bar\\\\name-with-n"]', $formatter->stringify(["indexed\narrays\nwithout\nkey", "foo\nbar\\name-with-n"]));
|
||||
self::assertSame('[{"first":"multi-dimensional'."\n".'arrays"},{"second":"foo'."\n".'bar\\\\name-with-n"}]', $formatter->stringify([["first" => "multi-dimensional\narrays"], ["second" => "foo\nbar\\name-with-n"]]));
|
||||
}
|
||||
|
||||
public function testDefFormatWithExceptionAndStacktraceParserFull()
|
||||
|
Reference in New Issue
Block a user