Pārlūkot izejas kodu

Add get/setLevel to AbstractLogger.

Justin Hileman 13 gadi atpakaļ
vecāks
revīzija
782017e461
1 mainītis faili ar 22 papildinājumiem un 0 dzēšanām
  1. 22 0
      src/Mustache/Logger/AbstractLogger.php

+ 22 - 0
src/Mustache/Logger/AbstractLogger.php

@@ -33,6 +33,18 @@ abstract class Mustache_Logger_AbstractLogger implements Mustache_Logger
      * @param  integer $level The minimum logging level which will be written
      */
     public function __construct($level = self::ERROR)
+    {
+        $this->setLevel($level);
+    }
+
+    /**
+     * Set the minimum logging level.
+     *
+     * @throws InvalidArgumentException if the logging level is unknown.
+     *
+     * @param  integer $level The minimum logging level which will be written
+     */
+    public function setLevel($level)
     {
         if (!array_key_exists($level, self::$levels)) {
             throw new InvalidArgumentException('Unexpected logging level: ' . $level);
@@ -41,6 +53,16 @@ abstract class Mustache_Logger_AbstractLogger implements Mustache_Logger
         $this->level = $level;
     }
 
+    /**
+     * Get the current minimum logging level.
+     *
+     * @return integer
+     */
+    public function getLevel()
+    {
+        return $this->level;
+    }
+
     /**
      * Adds a log record.
      *