diff --git a/packages/framework-extra-bundle/DependencyInjection/Compiler/LoggerDecoratorPass.php b/packages/framework-extra-bundle/DependencyInjection/Compiler/LoggerDecoratorPass.php index bee1487df..5bbd0ff6e 100644 --- a/packages/framework-extra-bundle/DependencyInjection/Compiler/LoggerDecoratorPass.php +++ b/packages/framework-extra-bundle/DependencyInjection/Compiler/LoggerDecoratorPass.php @@ -96,6 +96,7 @@ private function createDecoratorLoggerDefinition(array $tag): Definition return (new Definition(DecoratedLogger::class)) ->setArgument('defaultContext', $tag) - ->setArgument('decorateMessage', $message); + ->setArgument('decorateMessage', $message) + ->addTag('kernel.reset', ['method' => 'reset']); } } diff --git a/packages/log/DecoratedLogger.php b/packages/log/DecoratedLogger.php index 737179086..2b7751368 100644 --- a/packages/log/DecoratedLogger.php +++ b/packages/log/DecoratedLogger.php @@ -2,8 +2,10 @@ namespace Draw\Component\Log; +use Monolog\ResettableInterface; use Psr\Log\LoggerInterface; use Psr\Log\LoggerTrait; +use Symfony\Contracts\Service\ResetInterface; class DecoratedLogger implements LoggerInterface { @@ -27,4 +29,11 @@ public function log($level, $message, array $context = []): void array_merge($this->defaultContext, $context) ); } + + public function reset(): void + { + if ($this->logger instanceof ResetInterface || $this->logger instanceof ResettableInterface) { + $this->logger->reset(); + } + } }