"Fossies" - the Fresh Open Source Software Archive

Member "grav/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php" (8 Jun 2020, 1532 Bytes) of package /linux/www/grav-v1.6.26.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "AbstractProcessingHandler.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 /*
    4  * This file is part of the Monolog package.
    5  *
    6  * (c) Jordi Boggiano <j.boggiano@seld.be>
    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 Monolog\Handler;
   13 
   14 use Monolog\ResettableInterface;
   15 
   16 /**
   17  * Base Handler class providing the Handler structure
   18  *
   19  * Classes extending it should (in most cases) only implement write($record)
   20  *
   21  * @author Jordi Boggiano <j.boggiano@seld.be>
   22  * @author Christophe Coevoet <stof@notk.org>
   23  */
   24 abstract class AbstractProcessingHandler extends AbstractHandler
   25 {
   26     /**
   27      * {@inheritdoc}
   28      */
   29     public function handle(array $record)
   30     {
   31         if (!$this->isHandling($record)) {
   32             return false;
   33         }
   34 
   35         $record = $this->processRecord($record);
   36 
   37         $record['formatted'] = $this->getFormatter()->format($record);
   38 
   39         $this->write($record);
   40 
   41         return false === $this->bubble;
   42     }
   43 
   44     /**
   45      * Writes the record down to the log of the implementing handler
   46      *
   47      * @param  array $record
   48      * @return void
   49      */
   50     abstract protected function write(array $record);
   51 
   52     /**
   53      * Processes a record.
   54      *
   55      * @param  array $record
   56      * @return array
   57      */
   58     protected function processRecord(array $record)
   59     {
   60         if ($this->processors) {
   61             foreach ($this->processors as $processor) {
   62                 $record = call_user_func($processor, $record);
   63             }
   64         }
   65 
   66         return $record;
   67     }
   68 }