vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php line 44

  1. <?php declare(strict_types=1);
  2. /*
  3.  * This file is part of the Monolog package.
  4.  *
  5.  * (c) Jordi Boggiano <j.boggiano@seld.be>
  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 Monolog\Handler;
  11. use Monolog\LogRecord;
  12. /**
  13.  * Base Handler class providing the Handler structure, including processors and formatters
  14.  *
  15.  * Classes extending it should (in most cases) only implement write($record)
  16.  *
  17.  * @author Jordi Boggiano <j.boggiano@seld.be>
  18.  * @author Christophe Coevoet <stof@notk.org>
  19.  */
  20. abstract class AbstractProcessingHandler extends AbstractHandler implements ProcessableHandlerInterfaceFormattableHandlerInterface
  21. {
  22.     use ProcessableHandlerTrait;
  23.     use FormattableHandlerTrait;
  24.     /**
  25.      * @inheritDoc
  26.      */
  27.     public function handle(LogRecord $record): bool
  28.     {
  29.         if (!$this->isHandling($record)) {
  30.             return false;
  31.         }
  32.         if (\count($this->processors) > 0) {
  33.             $record $this->processRecord($record);
  34.         }
  35.         $record->formatted $this->getFormatter()->format($record);
  36.         $this->write($record);
  37.         return false === $this->bubble;
  38.     }
  39.     /**
  40.      * Writes the (already formatted) record down to the log of the implementing handler
  41.      */
  42.     abstract protected function write(LogRecord $record): void;
  43.     public function reset(): void
  44.     {
  45.         parent::reset();
  46.         $this->resetProcessors();
  47.     }
  48. }