Skip to content

Commit

Permalink
Allow to use env var for log levels of console logger
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Dec 19, 2022
1 parent aca8fb9 commit 320d493
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
13 changes: 0 additions & 13 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
12 changes: 6 additions & 6 deletions Tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public function testWithConsoleHandler()
'verbosity_levels' => [
'VERBOSITY_NORMAL' => 'NOTICE',
'verbosity_verbose' => 'info',
'VERBOSITY_very_VERBOSE' => '200'
'VERBOSITY_very_VERBOSE' => '200',
]
]
]
Expand All @@ -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']);
}

Expand Down

0 comments on commit 320d493

Please sign in to comment.