فهرست منبع

[HttpKernel] Added the context in the LoggerInterface

Christophe Coevoet 14 سال پیش
والد
کامیت
410b3e06d6

+ 1 - 0
src/Symfony/Bridge/Monolog/Handler/DebugHandler.php

@@ -34,6 +34,7 @@ class DebugHandler extends TestHandler implements DebugLoggerInterface
                 'message' => $record['message'],
                 'message' => $record['message'],
                 'priority' => $record['level'],
                 'priority' => $record['level'],
                 'priorityName' => $record['level_name'],
                 'priorityName' => $record['level_name'],
+                'context' => $record['context'],
             );
             );
         }
         }
 
 

+ 1 - 0
src/Symfony/Component/HttpKernel/Log/DebugLoggerInterface.php

@@ -23,6 +23,7 @@ interface DebugLoggerInterface
      *
      *
      * A log is an array with the following mandatory keys:
      * A log is an array with the following mandatory keys:
      * timestamp, message, priority, and priorityName.
      * timestamp, message, priority, and priorityName.
+     * It can also have an optionnal context key containing an array.
      *
      *
      * @return array An array of logs
      * @return array An array of logs
      */
      */

+ 8 - 8
src/Symfony/Component/HttpKernel/Log/LoggerInterface.php

@@ -18,19 +18,19 @@ namespace Symfony\Component\HttpKernel\Log;
  */
  */
 interface LoggerInterface
 interface LoggerInterface
 {
 {
-    function emerg($message);
+    function emerg($message, array $context = array());
 
 
-    function alert($message);
+    function alert($message, array $context = array());
 
 
-    function crit($message);
+    function crit($message, array $context = array());
 
 
-    function err($message);
+    function err($message, array $context = array());
 
 
-    function warn($message);
+    function warn($message, array $context = array());
 
 
-    function notice($message);
+    function notice($message, array $context = array());
 
 
-    function info($message);
+    function info($message, array $context = array());
 
 
-    function debug($message);
+    function debug($message, array $context = array());
 }
 }

+ 8 - 8
src/Symfony/Component/HttpKernel/Log/NullLogger.php

@@ -20,19 +20,19 @@ use Symfony\Component\HttpKernel\Log\LoggerInterface;
  */
  */
 class NullLogger implements LoggerInterface
 class NullLogger implements LoggerInterface
 {
 {
-    public function emerg($message) {}
+    public function emerg($message, array $context = array()) {}
 
 
-    public function alert($message) {}
+    public function alert($message, array $context = array()) {}
 
 
-    public function crit($message) {}
+    public function crit($message, array $context = array()) {}
 
 
-    public function err($message) {}
+    public function err($message, array $context = array()) {}
 
 
-    public function warn($message) {}
+    public function warn($message, array $context = array()) {}
 
 
-    public function notice($message) {}
+    public function notice($message, array $context = array()) {}
 
 
-    public function info($message) {}
+    public function info($message, array $context = array()) {}
 
 
-    public function debug($message) {}
+    public function debug($message, array $context = array()) {}
 }
 }

+ 8 - 8
tests/Symfony/Tests/Component/HttpKernel/Logger.php

@@ -46,42 +46,42 @@ class Logger implements LoggerInterface
         $this->logs[$priority][] = $message;
         $this->logs[$priority][] = $message;
     }
     }
 
 
-    public function emerg($message)
+    public function emerg($message, array $context = array())
     {
     {
         $this->log($message, 'emerg');
         $this->log($message, 'emerg');
     }
     }
 
 
-    public function alert($message)
+    public function alert($message, array $context = array())
     {
     {
         $this->log($message, 'alert');
         $this->log($message, 'alert');
     }
     }
 
 
-    public function crit($message)
+    public function crit($message, array $context = array())
     {
     {
         $this->log($message, 'crit');
         $this->log($message, 'crit');
     }
     }
 
 
-    public function err($message)
+    public function err($message, array $context = array())
     {
     {
         $this->log($message, 'err');
         $this->log($message, 'err');
     }
     }
 
 
-    public function warn($message)
+    public function warn($message, array $context = array())
     {
     {
         $this->log($message, 'warn');
         $this->log($message, 'warn');
     }
     }
 
 
-    public function notice($message)
+    public function notice($message, array $context = array())
     {
     {
         $this->log($message, 'notice');
         $this->log($message, 'notice');
     }
     }
 
 
-    public function info($message)
+    public function info($message, array $context = array())
     {
     {
         $this->log($message, 'info');
         $this->log($message, 'info');
     }
     }
 
 
-    public function debug($message)
+    public function debug($message, array $context = array())
     {
     {
         $this->log($message, 'debug');
         $this->log($message, 'debug');
     }
     }