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

Add ability to indent stack traces in LineFormatter, fixes #1835

This commit is contained in:
Jordi Boggiano
2023-10-27 16:19:09 +02:00
parent 5d317e2c6f
commit 8ff4ab5c94
2 changed files with 33 additions and 1 deletions

View File

@@ -13,6 +13,7 @@ namespace Monolog\Formatter;
use Monolog\Test\TestCase;
use Monolog\Level;
use RuntimeException;
/**
* @covers Monolog\Formatter\LineFormatter
@@ -277,6 +278,19 @@ class LineFormatterTest extends TestCase
$this->assertMatchesRegularExpression('/foo\nbar/', $message);
}
public function testIndentStackTraces(): void
{
$formatter = new LineFormatter();
$formatter->includeStacktraces();
//$formatter->allowInlineLineBreaks();
$formatter->indentStackTraces(' ');
$message = $formatter->format($this->getRecord(message: "foo", context: ['exception' => new RuntimeException('lala')]));
$this->assertStringContainsString(' [stacktrace]', $message);
$this->assertStringContainsString(' #0', $message);
$this->assertStringContainsString(' #1', $message);
}
/**
* @dataProvider providerMaxLevelNameLength
*/