From f44b0525d8be403a1c6aebc505612d20043dff34 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 23 Oct 2014 03:48:10 +0200 Subject: [PATCH] logging: Fix that setting a numeric log level is flawed --- library/Icinga/Logger/Logger.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Logger/Logger.php b/library/Icinga/Logger/Logger.php index 1cc820ef7..17f41ecba 100644 --- a/library/Icinga/Logger/Logger.php +++ b/library/Icinga/Logger/Logger.php @@ -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);