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

Remove empty lines if a custom stack trace parser returns null, fixes #1925

This commit is contained in:
Jordi Boggiano
2024-12-05 18:02:26 +01:00
parent 595847346a
commit 074503850b
2 changed files with 2 additions and 3 deletions

View File

@@ -309,6 +309,6 @@ class LineFormatter extends NormalizerFormatter
private function stacktracesParserCustom(string $trace): string
{
return implode("\n", array_filter(array_map($this->stacktracesParser, explode("\n", $trace)), fn ($line) => $line !== false && $line !== ''));
return implode("\n", array_filter(array_map($this->stacktracesParser, explode("\n", $trace)), fn ($line) => is_string($line) && trim($line) !== ''));
}
}

View File

@@ -193,10 +193,9 @@ class LineFormatterTest extends TestCase
});
$message = $formatter->format($this->getRecord(Level::Critical, context: ['exception' => new \RuntimeException('Foo')]));
$trace = explode('[stacktrace]', $message, 2)[1];
$this->assertStringNotContainsString('#', $trace);
$this->assertSame(PHP_EOL . PHP_EOL . '"} []' . PHP_EOL, $trace);
}
public function testDefFormatWithPreviousException()