vendor/easycorp/easy-log-handler/src/EasyLogHandler.php line 16

Open in your IDE?
  1. <?php
  2. namespace EasyCorp\EasyLog;
  3. use Monolog\Handler\StreamHandler;
  4. class EasyLogHandler extends StreamHandler
  5. {
  6.     /**
  7.      * @param resource|string $stream
  8.      */
  9.     public function __construct($stream)
  10.     {
  11.         parent::__construct($stream);
  12.         $this->formatter = new EasyLogFormatter();
  13.     }
  14.     /**
  15.      * @param array $record
  16.      */
  17.     public function handle(array $record): bool
  18.     {
  19.         throw new \RuntimeException('The method "handle()" should never be called (call "handleBatch()" instead). This is probably caused by a wrong "monolog" configuration. Please read EasyLogHandler README instructions to learn how to configure and use it.');
  20.     }
  21.     /**
  22.      * @param array $records
  23.      */
  24.     public function handleBatch(array $records): void
  25.     {
  26.         // if the log records were filtered (by channel, level, etc.) the array
  27.         // no longer contains consecutive numeric keys. Make them consecutive again
  28.         // before the log processing (this eases getting the next/previous record)
  29.         $records array_values($records);
  30.         if ($records) {
  31.             $this->write($this->getFormatter()->formatBatch($records));
  32.         }
  33.     }
  34. }