logging: Fix that setting a numeric log level is flawed

This commit is contained in:
Eric Lippmann 2014-10-23 03:48:10 +02:00
parent f68c591a46
commit f44b0525d8
1 changed files with 3 additions and 2 deletions

View File

@ -84,7 +84,8 @@ class Logger
if (($level = $config->level) !== null) {
if (is_numeric($level)) {
if (! isset(static::$levels[(int) $level])) {
$level = (int) $level;
if (! isset(static::$levels[$level])) {
throw new ConfigurationError(
'Can\'t set logging level %d. Logging level is not defined. Use one of %s or one of the'
. ' Logger\'s constants.',
@ -92,7 +93,7 @@ class Logger
implode(', ', array_keys(static::$levels))
);
}
$this->level = static::$levels[(int) $level];
$this->level = $level;
} else {
$level = strtoupper($level);
$levels = array_flip(static::$levels);