File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
DependencyInjection/Compiler Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 1515use Symfony \Component \DependencyInjection \ContainerBuilder ;
1616use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
1717use Symfony \Component \DependencyInjection \DefinitionDecorator ;
18+ use Symfony \Component \DependencyInjection \Exception \InvalidArgumentException ;
1819
1920/**
2021 * Replaces the default logger by another one with its own channel for tagged services.
2324 */
2425class LoggerChannelPass implements CompilerPassInterface
2526{
26- protected $ channels = array ();
27+ protected $ channels = array (' app ' );
2728
2829 public function process (ContainerBuilder $ container )
2930 {
@@ -50,7 +51,12 @@ public function process(ContainerBuilder $container)
5051
5152 foreach ($ handlersToChannels as $ handler => $ channels ) {
5253 foreach ($ this ->processChannels ($ channels ) as $ channel ) {
53- $ logger = $ container ->getDefinition ('monolog.logger. ' .$ channel );
54+ try {
55+ $ logger = $ container ->getDefinition ($ channel === 'app ' ? 'monolog.logger ' : 'monolog.logger. ' .$ channel );
56+ } catch (InvalidArgumentException $ e ) {
57+ $ msg = 'Monolog configuration error: The logging channel " ' .$ channel .'" assigned to the " ' .substr ($ handler , 16 ).'" handler does not exist. ' ;
58+ throw new \InvalidArgumentException ($ msg , 0 , $ e );
59+ }
5460 $ logger ->addMethodCall ('pushHandler ' , array (new Reference ($ handler )));
5561 }
5662 }
You can’t perform that action at this time.
0 commit comments