Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to use env var for log levels of console logger #448

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep this validation, we could evaluate the value at build time, but pass the configured value (with env placeholder).

https://github.com/symfony/monolog-bundle/pull/446/files#diff-3ee12206c3b122be4593dbfdb19397c16b3d337f759fad3bde6c785d6f1261c0L50-L75

'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