vendor/symfony/src/Symfony/Bridge/Monolog/Handler/DebugHandler.php
changeset 0 7f95f8617b0b
equal deleted inserted replaced
-1:000000000000 0:7f95f8617b0b
       
     1 <?php
       
     2 
       
     3 /*
       
     4  * This file is part of the Symfony package.
       
     5  *
       
     6  * (c) Fabien Potencier <fabien@symfony.com>
       
     7  *
       
     8  * For the full copyright and license information, please view the LICENSE
       
     9  * file that was distributed with this source code.
       
    10  */
       
    11 
       
    12 namespace Symfony\Bridge\Monolog\Handler;
       
    13 
       
    14 use Monolog\Logger;
       
    15 use Monolog\Handler\TestHandler;
       
    16 use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
       
    17 
       
    18 /**
       
    19  * DebugLogger.
       
    20  *
       
    21  * @author Jordi Boggiano <j.boggiano@seld.be>
       
    22  */
       
    23 class DebugHandler extends TestHandler implements DebugLoggerInterface
       
    24 {
       
    25     /**
       
    26      * {@inheritdoc}
       
    27      */
       
    28     public function getLogs()
       
    29     {
       
    30         $records = array();
       
    31         foreach ($this->records as $record) {
       
    32             $records[] = array(
       
    33                 'timestamp'    => $record['datetime']->getTimestamp(),
       
    34                 'message'      => $record['message'],
       
    35                 'priority'     => $record['level'],
       
    36                 'priorityName' => $record['level_name'],
       
    37                 'context'      => $record['context'],
       
    38             );
       
    39         }
       
    40 
       
    41         return $records;
       
    42     }
       
    43 
       
    44     /**
       
    45      * {@inheritdoc}
       
    46      */
       
    47     public function countErrors()
       
    48     {
       
    49         $cnt = 0;
       
    50         foreach (array(Logger::ERROR, Logger::CRITICAL, Logger::ALERT) as $level) {
       
    51             if (isset($this->recordsByLevel[$level])) {
       
    52                 $cnt += count($this->recordsByLevel[$level]);
       
    53             }
       
    54         }
       
    55 
       
    56         return $cnt;
       
    57     }
       
    58 }