11
11
12
12
namespace Symfony \Bundle \MonologBundle \DependencyInjection ;
13
13
14
+ use InvalidArgumentException ;
14
15
use Monolog \Logger ;
15
16
use Monolog \Processor \ProcessorInterface ;
16
17
use Monolog \ResettableInterface ;
@@ -467,6 +468,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
467
468
468
469
case 'group ' :
469
470
case 'whatfailuregroup ' :
471
+ case 'fallbackgroup ' :
470
472
$ references = [];
471
473
foreach ($ handler ['members ' ] as $ nestedHandler ) {
472
474
$ nestedHandlerId = $ this ->getHandlerId ($ nestedHandler );
@@ -479,7 +481,6 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
479
481
$ handler ['bubble ' ],
480
482
]);
481
483
break ;
482
-
483
484
case 'syslog ' :
484
485
$ definition ->setArguments ([
485
486
$ handler ['ident ' ],
@@ -857,7 +858,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
857
858
$ 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 ' ;
858
859
}
859
860
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 ));
861
862
}
862
863
863
864
if (!empty ($ handler ['nested ' ]) && true === $ handler ['nested ' ]) {
@@ -938,8 +939,33 @@ private function getHandlerClassByType($handlerType)
938
939
'insightops ' => 'Monolog\Handler\InsightOpsHandler ' ,
939
940
];
940
941
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
+
941
959
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
+ );
943
969
}
944
970
945
971
return $ typeToClassMapping [$ handlerType ];
0 commit comments