Skip to content

Commit 96b3e46

Browse files
committed
minor #253 Enforce that channels defined in the config are public loggers (stof)
This PR was merged into the 3.x-dev branch. Discussion ---------- Enforce that channels defined in the config are public loggers Channels can be created for 2 reasons: - because a service requests to use it through the monolog.logger tag, in which case a private channel is fine (as it is injected using the DIC) - because the bundle config asks to create it. In this case, the channel should be a public service, as the use case is to be able to use this channel through public access (otherwise, the previous way would have been used). This is an improved versions over #247 as only channels created through config become public in Symfony 4. /cc @derrabus Commits ------- 3f29cb2 Enforce that channels defined in the config are public loggers
2 parents cab593a + 3f29cb2 commit 96b3e46

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

DependencyInjection/Compiler/LoggerChannelPass.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function process(ContainerBuilder $container)
6868
foreach ($container->getParameter('monolog.additional_channels') as $chan) {
6969
$loggerId = sprintf('monolog.logger.%s', $chan);
7070
$this->createLogger($chan, $loggerId, $container);
71+
$container->getDefinition($loggerId)->setPublic(true);
7172
}
7273
$container->getParameterBag()->remove('monolog.additional_channels');
7374

0 commit comments

Comments
 (0)