3232use Symfony \Component \DependencyInjection \Loader \XmlFileLoader ;
3333use Symfony \Component \DependencyInjection \Reference ;
3434use Symfony \Component \HttpKernel \DependencyInjection \Extension ;
35- use Symfony \Component \HttpKernel \Kernel ;
3635use Symfony \Component \HttpKernel \Log \DebugLoggerConfigurator ;
3736use Symfony \Contracts \HttpClient \HttpClientInterface ;
3837
@@ -56,10 +55,6 @@ class MonologExtension extends Extension
5655 */
5756 public function load (array $ configs , ContainerBuilder $ container )
5857 {
59- if (class_exists (FullStack::class) && Kernel::MAJOR_VERSION < 5 && Logger::API >= 2 ) {
60- throw new \RuntimeException ('Symfony 5 is required for Monolog 2 support. Please downgrade Monolog to version 1. ' );
61- }
62-
6358 $ configuration = $ this ->getConfiguration ($ configs , $ container );
6459 $ config = $ this ->processConfiguration ($ configuration , $ configs );
6560
@@ -107,29 +102,27 @@ public function load(array $configs, ContainerBuilder $container)
107102
108103 $ container ->setParameter ('monolog.additional_channels ' , isset ($ config ['channels ' ]) ? $ config ['channels ' ] : []);
109104
110- if (method_exists ($ container , 'registerForAutoconfiguration ' )) {
111- if (interface_exists (ProcessorInterface::class)) {
112- $ container ->registerForAutoconfiguration (ProcessorInterface::class)
113- ->addTag ('monolog.processor ' );
114- } else {
115- $ container ->registerForAutoconfiguration (WebProcessor::class)
116- ->addTag ('monolog.processor ' );
117- }
118- if (interface_exists (ResettableInterface::class)) {
119- $ container ->registerForAutoconfiguration (ResettableInterface::class)
120- ->addTag ('kernel.reset ' , ['method ' => 'reset ' ]);
121- }
122- $ container ->registerForAutoconfiguration (TokenProcessor::class)
105+ if (interface_exists (ProcessorInterface::class)) {
106+ $ container ->registerForAutoconfiguration (ProcessorInterface::class)
123107 ->addTag ('monolog.processor ' );
124- if (interface_exists (HttpClientInterface::class)) {
125- $ handlerAutoconfiguration = $ container ->registerForAutoconfiguration (HandlerInterface::class);
126- $ handlerAutoconfiguration ->setBindings ($ handlerAutoconfiguration ->getBindings () + [
127- HttpClientInterface::class => new BoundArgument (new Reference ('monolog.http_client ' ), false ),
128- ]);
129- }
108+ } else {
109+ $ container ->registerForAutoconfiguration (WebProcessor::class)
110+ ->addTag ('monolog.processor ' );
111+ }
112+ if (interface_exists (ResettableInterface::class)) {
113+ $ container ->registerForAutoconfiguration (ResettableInterface::class)
114+ ->addTag ('kernel.reset ' , ['method ' => 'reset ' ]);
115+ }
116+ $ container ->registerForAutoconfiguration (TokenProcessor::class)
117+ ->addTag ('monolog.processor ' );
118+ if (interface_exists (HttpClientInterface::class)) {
119+ $ handlerAutoconfiguration = $ container ->registerForAutoconfiguration (HandlerInterface::class);
120+ $ handlerAutoconfiguration ->setBindings ($ handlerAutoconfiguration ->getBindings () + [
121+ HttpClientInterface::class => new BoundArgument (new Reference ('monolog.http_client ' ), false ),
122+ ]);
130123 }
131124
132- if (80000 <= \PHP_VERSION_ID && method_exists ( $ container , ' registerAttributeForAutoconfiguration ' ) ) {
125+ if (80000 <= \PHP_VERSION_ID ) {
133126 $ container ->registerAttributeForAutoconfiguration (AsMonologProcessor::class, static function (ChildDefinition $ definition , AsMonologProcessor $ attribute , \Reflector $ reflector ): void {
134127 $ tagAttributes = get_object_vars ($ attribute );
135128 if ($ reflector instanceof \ReflectionMethod) {
@@ -431,9 +424,6 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
431424 $ container ->setDefinition ($ handlerId .'.not_found_strategy ' , $ activationDef );
432425 $ activation = new Reference ($ handlerId .'.not_found_strategy ' );
433426 } elseif (!empty ($ handler ['excluded_http_codes ' ])) {
434- if (!class_exists ('Symfony\Bridge\Monolog\Handler\FingersCrossed\HttpCodeActivationStrategy ' )) {
435- throw new \LogicException ('"excluded_http_codes" cannot be used as your version of Monolog bridge does not support it. ' );
436- }
437427 $ activationDef = new Definition ('Symfony\Bridge\Monolog\Handler\FingersCrossed\HttpCodeActivationStrategy ' , [
438428 new Reference ('request_stack ' ),
439429 $ handler ['excluded_http_codes ' ],
@@ -888,10 +878,6 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
888878 ]);
889879 break ;
890880 case 'server_log ' :
891- if (!class_exists ('Symfony\Bridge\Monolog\Handler\ServerLogHandler ' )) {
892- throw new \RuntimeException ('The ServerLogHandler is not available. Please update "symfony/monolog-bridge" to 3.3. ' );
893- }
894-
895881 $ definition ->setArguments ([
896882 $ handler ['host ' ],
897883 $ handler ['level ' ],
0 commit comments