From d7a31bd18a3a48043834ebf6dce26534030b5eb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Mon, 19 Dec 2022 23:25:33 +0100 Subject: [PATCH] Allow to use env var for log levels of console logger --- DependencyInjection/Configuration.php | 13 ------------- Tests/DependencyInjection/ConfigurationTest.php | 12 ++++++------ 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 7dea0247..31ab8010 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -1047,19 +1047,6 @@ private function addVerbosityLevelSection(ArrayNodeDefinition $handerNode) )); } - try { - if (Logger::API === 3) { - $level = Logger::toMonologLevel($level)->value; - } else { - $level = Logger::toMonologLevel(is_numeric($level) ? (int) $level : $level); - } - } catch (\Psr\Log\InvalidArgumentException $e) { - throw new InvalidConfigurationException(sprintf( - 'The configured minimum log level "%s" for verbosity "%s" is invalid as it is not defined in Monolog\Logger.', - $level, $verbosity - )); - } - $map[constant($verbosityConstant)] = $level; } diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php index 38847364..7f76cd75 100644 --- a/Tests/DependencyInjection/ConfigurationTest.php +++ b/Tests/DependencyInjection/ConfigurationTest.php @@ -278,7 +278,7 @@ public function testWithConsoleHandler() 'verbosity_levels' => [ 'VERBOSITY_NORMAL' => 'NOTICE', 'verbosity_verbose' => 'info', - 'VERBOSITY_very_VERBOSE' => '200' + 'VERBOSITY_very_VERBOSE' => '200', ] ] ] @@ -289,11 +289,11 @@ public function testWithConsoleHandler() $this->assertSame('console', $config['handlers']['console']['type']); $this->assertSame([ - OutputInterface::VERBOSITY_NORMAL => Logger::NOTICE, - OutputInterface::VERBOSITY_VERBOSE => Logger::INFO, - OutputInterface::VERBOSITY_VERY_VERBOSE => 200, - OutputInterface::VERBOSITY_QUIET => Logger::ERROR, - OutputInterface::VERBOSITY_DEBUG => Logger::DEBUG + OutputInterface::VERBOSITY_NORMAL => 'NOTICE', + OutputInterface::VERBOSITY_VERBOSE => 'INFO', + OutputInterface::VERBOSITY_VERY_VERBOSE => '200', + OutputInterface::VERBOSITY_QUIET => 'ERROR', + OutputInterface::VERBOSITY_DEBUG => 'DEBUG', ], $config['handlers']['console']['verbosity_levels']); }