Skip to content

Commit 1dc7e60

Browse files
committed
feature #36621 Log deprecations on a dedicated Monolog channel (l-vo)
This PR was squashed before being merged into the 5.1-dev branch. Discussion ---------- Log deprecations on a dedicated Monolog channel | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | https://github.com/orgs/symfony/projects/1#card-35233930 | License | MIT | Doc PR | This PR allows to activate a specific channel for deprecations. ## Base configuration ```yaml monolog: handlers: #... deprecation: type: stream path: "%kernel.logs_dir%/%kernel.environment%.deprecations.log" deprecation_filter: type: filter handler: deprecation max_level: info channels: ["php"] ``` ## Deprecation specific channel enabled: ```yaml monolog: channels: ['deprecation'] handlers: #... deprecation: type: stream channels: ["deprecation"] path: "%kernel.logs_dir%/%kernel.environment%.deprecations.log" ``` Commits ------- 3d415cb70d Log deprecations on a dedicated Monolog channel
2 parents 7d15dee + 96842d9 commit 1dc7e60

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Resources/config/debug_prod.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
<tag name="kernel.event_subscriber" />
1616
<tag name="monolog.logger" channel="php" />
1717
<argument>null</argument><!-- Exception handler -->
18-
<argument type="service" id="logger" on-invalid="null" />
18+
<argument type="service" id="monolog.logger.php" on-invalid="null" />
1919
<argument>null</argument><!-- Log levels map for enabled error levels -->
2020
<argument>%debug.error_handler.throw_at%</argument>
2121
<argument>%kernel.debug%</argument>
2222
<argument type="service" id="debug.file_link_formatter" />
2323
<argument>%kernel.debug%</argument>
24+
<argument type="service" id="monolog.logger.deprecation" on-invalid="null" />
2425
</service>
2526

2627
<service id="debug.file_link_formatter" class="Symfony\Component\HttpKernel\Debug\FileLinkFormatter">

Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ public function testEnabledPhpErrorsConfig()
425425
$container = $this->createContainerFromFile('php_errors_enabled');
426426

427427
$definition = $container->getDefinition('debug.debug_handlers_listener');
428-
$this->assertEquals(new Reference('logger', ContainerInterface::NULL_ON_INVALID_REFERENCE), $definition->getArgument(1));
428+
$this->assertEquals(new Reference('monolog.logger.php', ContainerInterface::NULL_ON_INVALID_REFERENCE), $definition->getArgument(1));
429429
$this->assertNull($definition->getArgument(2));
430430
$this->assertSame(-1, $container->getParameter('debug.error_handler.throw_at'));
431431
}
@@ -445,7 +445,7 @@ public function testPhpErrorsWithLogLevel()
445445
$container = $this->createContainerFromFile('php_errors_log_level');
446446

447447
$definition = $container->getDefinition('debug.debug_handlers_listener');
448-
$this->assertEquals(new Reference('logger', ContainerInterface::NULL_ON_INVALID_REFERENCE), $definition->getArgument(1));
448+
$this->assertEquals(new Reference('monolog.logger.php', ContainerInterface::NULL_ON_INVALID_REFERENCE), $definition->getArgument(1));
449449
$this->assertSame(8, $definition->getArgument(2));
450450
}
451451

0 commit comments

Comments
 (0)