1111
1212namespace Symfony \Bundle \MonologBundle \DependencyInjection ;
1313
14+ use InvalidArgumentException ;
1415use Monolog \Logger ;
1516use Monolog \Processor \ProcessorInterface ;
1617use Monolog \ResettableInterface ;
@@ -467,6 +468,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
467468
468469 case 'group ' :
469470 case 'whatfailuregroup ' :
471+ case 'fallbackgroup ' :
470472 $ references = [];
471473 foreach ($ handler ['members ' ] as $ nestedHandler ) {
472474 $ nestedHandlerId = $ this ->getHandlerId ($ nestedHandler );
@@ -479,7 +481,6 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
479481 $ handler ['bubble ' ],
480482 ]);
481483 break ;
482-
483484 case 'syslog ' :
484485 $ definition ->setArguments ([
485486 $ handler ['ident ' ],
@@ -857,7 +858,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
857858 $ nullWarning = ', if you meant to define a null handler in a yaml config, make sure you quote "null" so it does not get converted to a php null ' ;
858859 }
859860
860- throw new \ InvalidArgumentException (sprintf ('Invalid handler type "%s" given for handler "%s" ' . $ nullWarning , $ handler ['type ' ], $ name ));
861+ throw new InvalidArgumentException (sprintf ('Invalid handler type "%s" given for handler "%s" ' . $ nullWarning , $ handler ['type ' ], $ name ));
861862 }
862863
863864 if (!empty ($ handler ['nested ' ]) && true === $ handler ['nested ' ]) {
@@ -938,8 +939,33 @@ private function getHandlerClassByType($handlerType)
938939 'insightops ' => 'Monolog\Handler\InsightOpsHandler ' ,
939940 ];
940941
942+ $ typeToClassMappingV2Added = [
943+ 'fallbackgroup ' => 'Monolog\Handler\FallbackGroupHandler ' ,
944+ ];
945+
946+ $ typeToClassMappingV2Removed = [
947+ 'hipchat ' ,
948+ 'raven ' ,
949+ ];
950+
951+ if (Logger::API === 2 ) {
952+ $ typeToClassMapping = array_merge ($ typeToClassMapping , $ typeToClassMappingV2Added );
953+
954+ foreach ($ typeToClassMappingV2Removed as $ key ) {
955+ unset($ typeToClassMapping [$ key ]);
956+ }
957+ }
958+
941959 if (!isset ($ typeToClassMapping [$ handlerType ])) {
942- throw new \InvalidArgumentException (sprintf ('There is no handler class defined for handler "%s". ' , $ handlerType ));
960+ if (array_key_exists ($ handlerType , $ typeToClassMappingV2Added )) {
961+ throw new InvalidArgumentException (
962+ sprintf ('"%s" was added in MonoLog 2. ' , $ handlerType )
963+ );
964+ }
965+
966+ throw new InvalidArgumentException (
967+ sprintf ('There is no handler class defined for handler "%s". ' , $ handlerType )
968+ );
943969 }
944970
945971 return $ typeToClassMapping [$ handlerType ];
0 commit comments