Преглед изворни кода

[MonologBundle] Fix DebugHandler to match Symfony's interface

Jordi Boggiano пре 14 година
родитељ
комит
8176cb220b
1 измењених фајлова са 13 додато и 3 уклоњено
  1. 13 3
      src/Symfony/Bundle/MonologBundle/Logger/DebugHandler.php

+ 13 - 3
src/Symfony/Bundle/MonologBundle/Logger/DebugHandler.php

@@ -12,7 +12,6 @@
 namespace Symfony\Bundle\MonologBundle\Logger;
 
 use Monolog\Handler\TestHandler;
-use Monolog\Logger;
 use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
 
 /**
@@ -27,7 +26,16 @@ class DebugHandler extends TestHandler implements DebugLoggerInterface
      */
     public function getLogs()
     {
-        return $this->messages;
+        $records = array();
+        foreach ($this->records as $record) {
+            $records[] = array(
+                'timestamp' => $record['datetime']->getTimestamp(),
+                'message' => $record['message'],
+                'priority' => $record['level'],
+                'priorityName' => $record['level_name'],
+            );
+        }
+        return $records;
     }
 
     /**
@@ -35,6 +43,8 @@ class DebugHandler extends TestHandler implements DebugLoggerInterface
      */
     public function countErrors()
     {
-        return count($this->messagesByLevel[Logger::ERROR]);
+        return isset($this->recordsByLevel[\Monolog\Logger::ERROR])
+            ? count($this->recordsByLevel[\Monolog\Logger::ERROR])
+            : 0;
     }
 }