1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-08 06:06:40 +02:00

Include extra in context in PsrHandler (#1852)

This commit is contained in:
Witold Wasiczko
2024-04-12 11:00:56 +02:00
committed by GitHub
parent 000fedbcf2
commit 35dab43e3c
2 changed files with 28 additions and 7 deletions

View File

@@ -60,4 +60,20 @@ class PsrHandlerTest extends TestCase
$handler->setFormatter(new LineFormatter('dummy'));
$handler->handle($this->getRecord($level, $message, context: $context, datetime: new \DateTimeImmutable()));
}
public function testIncludeExtra()
{
$message = 'Hello, world!';
$context = ['foo' => 'bar'];
$extra = ['baz' => 'boo'];
$level = Level::Error;
$psrLogger = $this->createMock('Psr\Log\NullLogger');
$psrLogger->expects($this->once())
->method('log')
->with($level->toPsrLogLevel(), $message, ['baz' => 'boo', 'foo' => 'bar']);
$handler = new PsrHandler($psrLogger, includeExtra: true);
$handler->handle($this->getRecord($level, $message, context: $context, datetime: new \DateTimeImmutable(), extra: $extra));
}
}