Skip to content

Commit 983675a

Browse files
committed
Allow to use env var for log levels of console logger
1 parent 0e136c5 commit 983675a

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

DependencyInjection/Configuration.php

-13
Original file line numberDiff line numberDiff line change
@@ -1047,19 +1047,6 @@ private function addVerbosityLevelSection(ArrayNodeDefinition $handerNode)
10471047
));
10481048
}
10491049

1050-
try {
1051-
if (Logger::API === 3) {
1052-
$level = Logger::toMonologLevel($level)->value;
1053-
} else {
1054-
$level = Logger::toMonologLevel(is_numeric($level) ? (int) $level : $level);
1055-
}
1056-
} catch (\Psr\Log\InvalidArgumentException $e) {
1057-
throw new InvalidConfigurationException(sprintf(
1058-
'The configured minimum log level "%s" for verbosity "%s" is invalid as it is not defined in Monolog\Logger.',
1059-
$level, $verbosity
1060-
));
1061-
}
1062-
10631050
$map[constant($verbosityConstant)] = $level;
10641051
}
10651052

Tests/DependencyInjection/ConfigurationTest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ public function testWithConsoleHandler()
278278
'verbosity_levels' => [
279279
'VERBOSITY_NORMAL' => 'NOTICE',
280280
'verbosity_verbose' => 'info',
281-
'VERBOSITY_very_VERBOSE' => '200'
281+
'VERBOSITY_very_VERBOSE' => '200',
282282
]
283283
]
284284
]
@@ -289,11 +289,11 @@ public function testWithConsoleHandler()
289289

290290
$this->assertSame('console', $config['handlers']['console']['type']);
291291
$this->assertSame([
292-
OutputInterface::VERBOSITY_NORMAL => Logger::NOTICE,
293-
OutputInterface::VERBOSITY_VERBOSE => Logger::INFO,
294-
OutputInterface::VERBOSITY_VERY_VERBOSE => 200,
295-
OutputInterface::VERBOSITY_QUIET => Logger::ERROR,
296-
OutputInterface::VERBOSITY_DEBUG => Logger::DEBUG
292+
OutputInterface::VERBOSITY_NORMAL => 'NOTICE',
293+
OutputInterface::VERBOSITY_VERBOSE => 'INFO',
294+
OutputInterface::VERBOSITY_VERY_VERBOSE => '200',
295+
OutputInterface::VERBOSITY_QUIET => 'ERROR',
296+
OutputInterface::VERBOSITY_DEBUG => 'DEBUG',
297297
], $config['handlers']['console']['verbosity_levels']);
298298
}
299299

0 commit comments

Comments
 (0)