From d576ff5b57a3dafe191d75776a75c07a227f6002 Mon Sep 17 00:00:00 2001 From: HypeMC Date: Wed, 24 Sep 2025 21:13:33 +0200 Subject: [PATCH] Require Symfony 6.4 and PHP 8.1 --- .github/workflows/ci.yaml | 17 +++------ CHANGELOG.md | 2 ++ composer.json | 14 ++++---- src/DependencyInjection/MonologExtension.php | 38 +++++++++----------- 4 files changed, 30 insertions(+), 41 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e6b3e17f..459ed51f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,28 +13,19 @@ jobs: matrix: php: [ '8.1', '8.2', '8.3', '8.4' ] monolog: [ '2.*' ] - symfony: [ '6.4.*' ] + symfony: [ false ] include: - - php: '7.2' - symfony: '5.4.*' - monolog: '1.*' - - php: '7.4' + - php: '8.1' deps: lowest - symfony: '5.4.*' + symfony: '6.4.*' + monolog: '1.*' deprecations: max[self]=0 - php: '8.1' monolog: '3.*' symfony: '6.4.*' - - php: '8.2' - monolog: '3.*' - symfony: '7.3.*' - - php: '8.3' - monolog: '3.*' - symfony: '7.3.*' - php: '8.4' deps: highest monolog: '3.*' - symfony: '7.4.*' env: SYMFONY_REQUIRE: ${{ matrix.symfony }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c8e0301..1dc3b1c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ * Add `slack.exclude_fields` and `slackwebhook.exclude_fields` configuration * Add a processor to all loggers only when tags do not specify a channel or handler * Deprecate abstract `monolog.activation_strategy.not_found` and `monolog.handler.fingers_crossed.error_level_activation_strategy` service definitions +* Drop support for PHP < 8.1 +* Drop support for Symfony < 6.4 ## 3.10.0 (2023-11-06) diff --git a/composer.json b/composer.json index c13fddb7..e66dfeff 100644 --- a/composer.json +++ b/composer.json @@ -16,19 +16,19 @@ } ], "require": { - "php": ">=7.2.5", + "php": ">=8.1", "composer-runtime-api": "^2.0", "monolog/monolog": "^1.25.1 || ^2.0 || ^3.0", - "symfony/config": "^5.4 || ^6.0 || ^7.0", - "symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0", - "symfony/http-kernel": "^5.4 || ^6.0 || ^7.0", - "symfony/monolog-bridge": "^5.4 || ^6.0 || ^7.0", + "symfony/config": "^6.4 || ^7.0", + "symfony/dependency-injection": "^6.4 || ^7.0", + "symfony/http-kernel": "^6.4 || ^7.0", + "symfony/monolog-bridge": "^6.4 || ^7.0", "symfony/polyfill-php84": "^1.30" }, "require-dev": { - "symfony/console": "^5.4 || ^6.0 || ^7.0", + "symfony/console": "^6.4 || ^7.0", "symfony/phpunit-bridge": "^7.1", - "symfony/yaml": "^5.4 || ^6.0 || ^7.0" + "symfony/yaml": "^6.4 || ^7.0" }, "autoload": { "psr-4": { "Symfony\\Bundle\\MonologBundle\\": "src" } diff --git a/src/DependencyInjection/MonologExtension.php b/src/DependencyInjection/MonologExtension.php index afa2b280..0ef2af0e 100644 --- a/src/DependencyInjection/MonologExtension.php +++ b/src/DependencyInjection/MonologExtension.php @@ -20,7 +20,6 @@ use Monolog\Processor\PsrLogMessageProcessor; use Monolog\ResettableInterface; use Symfony\Bridge\Monolog\Handler\FingersCrossed\HttpCodeActivationStrategy; -use Symfony\Bridge\Monolog\Logger as LegacyLogger; use Symfony\Bridge\Monolog\Processor\SwitchUserTokenProcessor; use Symfony\Bridge\Monolog\Processor\TokenProcessor; use Symfony\Bridge\Monolog\Processor\WebProcessor; @@ -32,7 +31,6 @@ use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpKernel\DependencyInjection\Extension; -use Symfony\Component\HttpKernel\Log\DebugLoggerConfigurator; use Symfony\Contracts\HttpClient\HttpClientInterface; /** @@ -64,10 +62,6 @@ public function load(array $configs, ContainerBuilder $container) $loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../../config')); $loader->load('monolog.php'); - if (!class_exists(DebugLoggerConfigurator::class)) { - $container->getDefinition('monolog.logger_prototype')->setClass(LegacyLogger::class); - } - $container->setParameter('monolog.use_microseconds', $config['use_microseconds']); $handlers = []; @@ -116,6 +110,7 @@ public function load(array $configs, ContainerBuilder $container) } $container->registerForAutoconfiguration(TokenProcessor::class) ->addTag('monolog.processor'); + if (interface_exists(HttpClientInterface::class)) { $handlerAutoconfiguration = $container->registerForAutoconfiguration(HandlerInterface::class); $handlerAutoconfiguration->setBindings($handlerAutoconfiguration->getBindings() + [ @@ -123,23 +118,21 @@ public function load(array $configs, ContainerBuilder $container) ]); } - if (80000 <= \PHP_VERSION_ID) { - $container->registerAttributeForAutoconfiguration(AsMonologProcessor::class, static function (ChildDefinition $definition, AsMonologProcessor $attribute, \Reflector $reflector): void { - $tagAttributes = get_object_vars($attribute); - if ($reflector instanceof \ReflectionMethod) { - if (isset($tagAttributes['method'])) { - throw new \LogicException(\sprintf('AsMonologProcessor attribute cannot declare a method on "%s::%s()".', $reflector->class, $reflector->name)); - } - - $tagAttributes['method'] = $reflector->getName(); + $container->registerAttributeForAutoconfiguration(AsMonologProcessor::class, static function (ChildDefinition $definition, AsMonologProcessor $attribute, \Reflector $reflector): void { + $tagAttributes = get_object_vars($attribute); + if ($reflector instanceof \ReflectionMethod) { + if (isset($tagAttributes['method'])) { + throw new \LogicException(\sprintf('AsMonologProcessor attribute cannot declare a method on "%s::%s()".', $reflector->class, $reflector->name)); } - $definition->addTag('monolog.processor', $tagAttributes); - }); - $container->registerAttributeForAutoconfiguration(WithMonologChannel::class, static function (ChildDefinition $definition, WithMonologChannel $attribute): void { - $definition->addTag('monolog.logger', ['channel' => $attribute->channel]); - }); - } + $tagAttributes['method'] = $reflector->getName(); + } + + $definition->addTag('monolog.processor', $tagAttributes); + }); + $container->registerAttributeForAutoconfiguration(WithMonologChannel::class, static function (ChildDefinition $definition, WithMonologChannel $attribute): void { + $definition->addTag('monolog.logger', ['channel' => $attribute->channel]); + }); } /** @@ -877,6 +870,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler $handler['bubble'], ]); break; + case 'newrelic': $definition->setArguments([ $handler['level'], @@ -884,6 +878,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler $handler['app_name'], ]); break; + case 'server_log': $definition->setArguments([ $handler['host'], @@ -891,6 +886,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler $handler['bubble'], ]); break; + case 'sampling': $nestedHandlerId = $this->getHandlerId($handler['handler']); $this->markNestedHandler($nestedHandlerId);