tweak hasLevel() and use it in addLevel()
authorChuck Hagenbuch <chuck@horde.org>
Fri, 25 Sep 2009 17:12:07 +0000 (13:12 -0400)
committerChuck Hagenbuch <chuck@horde.org>
Fri, 25 Sep 2009 17:50:37 +0000 (13:50 -0400)
framework/Log/lib/Horde/Log/Logger.php

index eb3fb98..37fc2ab 100644 (file)
@@ -147,7 +147,7 @@ class Horde_Log_Logger
      */
     public function hasLevel($name)
     {
-        return array_search($name, $this->_levels);
+        return (boolean)array_search($name, $this->_levels);
     }
 
     /**
@@ -162,8 +162,7 @@ class Horde_Log_Logger
         // Log level names must be uppercase for predictability.
         $name = strtoupper($name);
 
-        if (isset($this->_levels[$level])
-            || array_search($name, $this->_levels)) {
+        if (isset($this->_levels[$level]) || $this->hasLevel($name)) {
             throw new Horde_Log_Exception('Existing log levels cannot be overwritten');
         }