media-cloud-sync
/
includes
/
sdk
/
google
/
monolog
/
monolog
/
src
/
Monolog
/
Handler
/
AbstractProcessingHandler.php
AbstractProcessingHandler.php in Media Cloud Sync 1.4.2, at includes/sdk/google/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php
| 1 | <?php |
| 2 | |
| 3 | declare (strict_types=1); |
| 4 | /* |
| 5 | * This file is part of the Monolog package. |
| 6 | * |
| 7 | * (c) Jordi Boggiano <[email protected]> |
| 8 | * |
| 9 | * For the full copyright and license information, please view the LICENSE |
| 10 | * file that was distributed with this source code. |
| 11 | */ |
| 12 | namespace Dudlewebs\WPMCS\GCP\Monolog\Handler; |
| 13 | |
| 14 | use Dudlewebs\WPMCS\GCP\Monolog\LogRecord; |
| 15 | /** |
| 16 | * Base Handler class providing the Handler structure, including processors and formatters |
| 17 | * |
| 18 | * Classes extending it should (in most cases) only implement write($record) |
| 19 | * |
| 20 | * @author Jordi Boggiano <[email protected]> |
| 21 | * @author Christophe Coevoet <[email protected]> |
| 22 | */ |
| 23 | abstract class AbstractProcessingHandler extends AbstractHandler implements ProcessableHandlerInterface, FormattableHandlerInterface |
| 24 | { |
| 25 | use ProcessableHandlerTrait; |
| 26 | use FormattableHandlerTrait; |
| 27 | /** |
| 28 | * @inheritDoc |
| 29 | */ |
| 30 | public function handle(LogRecord $record) : bool |
| 31 | { |
| 32 | if (!$this->isHandling($record)) { |
| 33 | return \false; |
| 34 | } |
| 35 | if (\count($this->processors) > 0) { |
| 36 | $record = $this->processRecord($record); |
| 37 | } |
| 38 | $record->formatted = $this->getFormatter()->format($record); |
| 39 | $this->write($record); |
| 40 | return \false === $this->bubble; |
| 41 | } |
| 42 | /** |
| 43 | * Writes the (already formatted) record down to the log of the implementing handler |
| 44 | */ |
| 45 | protected abstract function write(LogRecord $record) : void; |
| 46 | public function reset() : void |
| 47 | { |
| 48 | parent::reset(); |
| 49 | $this->resetProcessors(); |
| 50 | } |
| 51 | } |
| 52 |