vendor/symfony/symfony/src/Symfony/Bridge/Monolog/Handler/DebugHandler.php line 14

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Bridge\Monolog\Handler;
  11. @trigger_error('The '.__NAMESPACE__.'\DebugHandler class is deprecated since Symfony 3.2 and will be removed in 4.0. Use Symfony\Bridge\Monolog\Processor\DebugProcessor instead.', \E_USER_DEPRECATED);
  12. use Monolog\Handler\TestHandler;
  13. use Monolog\Logger;
  14. use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
  15. /**
  16.  * DebugLogger.
  17.  *
  18.  * @author Jordi Boggiano <j.boggiano@seld.be>
  19.  *
  20.  * @deprecated since version 3.2, to be removed in 4.0. Use Symfony\Bridge\Monolog\Processor\DebugProcessor instead.
  21.  */
  22. class DebugHandler extends TestHandler implements DebugLoggerInterface
  23. {
  24.     /**
  25.      * {@inheritdoc}
  26.      */
  27.     public function getLogs()
  28.     {
  29.         $records = [];
  30.         foreach ($this->records as $record) {
  31.             $records[] = [
  32.                 'timestamp' => $record['datetime']->getTimestamp(),
  33.                 'message' => $record['message'],
  34.                 'priority' => $record['level'],
  35.                 'priorityName' => $record['level_name'],
  36.                 'context' => $record['context'],
  37.                 'channel' => isset($record['channel']) ? $record['channel'] : '',
  38.             ];
  39.         }
  40.         return $records;
  41.     }
  42.     /**
  43.      * {@inheritdoc}
  44.      */
  45.     public function countErrors()
  46.     {
  47.         $cnt 0;
  48.         $levels = [Logger::ERRORLogger::CRITICALLogger::ALERTLogger::EMERGENCY];
  49.         foreach ($levels as $level) {
  50.             if (isset($this->recordsByLevel[$level])) {
  51.                 $cnt += \count($this->recordsByLevel[$level]);
  52.             }
  53.         }
  54.         return $cnt;
  55.     }
  56. }