From 4504216af89b9547cd00b6447e56dbbe7fe272c6 Mon Sep 17 00:00:00 2001 From: aubes <3941035+aubes@users.noreply.github.com> Date: Wed, 25 Mar 2026 19:39:55 +0100 Subject: [PATCH] Fix default handler and channel per processor --- .gitattributes | 2 -- CHANGELOG.md | 6 ++++++ src/DependencyInjection/ProcessorLoader.php | 12 ++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.gitattributes b/.gitattributes index 9ac07e3..83138ad 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,8 +1,6 @@ /.github export-ignore /tests export-ignore /.php-cs-fixer.php export-ignore -/.pmd-ruleset.xml export-ignore /.gitattributes export-ignore /.gitignore export-ignore /phpunit.xml.dist export-ignore -/psalm.xml export-ignore \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index d70490e..ef35202 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.0.1] + +### Fixed + +- Per-processor `channels`/`handlers` routing no longer inherits global defaults when the processor defines its own routing. Previously, a processor with only `handlers` configured would also inherit global `channels`, causing an "cannot target both channels and handlers" error. + ## [3.0.0] ### Breaking Changes diff --git a/src/DependencyInjection/ProcessorLoader.php b/src/DependencyInjection/ProcessorLoader.php index b4eaee6..b3e73be 100644 --- a/src/DependencyInjection/ProcessorLoader.php +++ b/src/DependencyInjection/ProcessorLoader.php @@ -205,8 +205,16 @@ private function resolveUserProvider(array $processorConfig): Definition|Referen */ private function configureMonologProcessor(array $config, array $configOverride, Definition $processor, int $priority = 0): void { - $channels = !empty($configOverride['channels']) ? $configOverride['channels'] : $config['monolog']['channels']; - $handlers = !empty($configOverride['handlers']) ? $configOverride['handlers'] : $config['monolog']['handlers']; + $processorHasChannels = !empty($configOverride['channels']); + $processorHasHandlers = !empty($configOverride['handlers']); + + if ($processorHasChannels || $processorHasHandlers) { + $channels = $configOverride['channels']; + $handlers = $configOverride['handlers']; + } else { + $channels = $config['monolog']['channels']; + $handlers = $config['monolog']['handlers']; + } if (!empty($channels) && !empty($handlers)) { throw new InvalidConfigurationException('ecs_logging: a processor cannot target both channels and handlers simultaneously. Configure one or the other.');