| 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 |
/** |
| 13 |
* Base Handler class providing the Handler structure |
| 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 Monolog_Handler_AbstractProcessingHandler extends Monolog_Handler_AbstractHandler |
| 21 |
{ |
| 22 |
/** |
| 23 |
* {@inheritdoc} |
| 24 |
*/ |
| 25 |
public function handle(array $record) |
| 26 |
{ |
| 27 |
if (!$this->isHandling($record)) { |
| 28 |
return false; |
| 29 |
} |
| 30 |
|
| 31 |
$record = $this->processRecord($record); |
| 32 |
|
| 33 |
$record['formatted'] = $this->getFormatter()->format($record); |
| 34 |
|
| 35 |
$this->write($record); |
| 36 |
|
| 37 |
return false === $this->bubble; |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* Writes the record down to the log of the implementing handler |
| 42 |
* |
| 43 |
* @param array $record |
| 44 |
* |
| 45 |
* @return void |
| 46 |
*/ |
| 47 |
abstract protected function write(array $record); |
| 48 |
|
| 49 |
/** |
| 50 |
* Processes a record. |
| 51 |
* |
| 52 |
* @param array $record |
| 53 |
* |
| 54 |
* @return array |
| 55 |
*/ |
| 56 |
protected function processRecord(array $record) |
| 57 |
{ |
| 58 |
if ($this->processors) { |
| 59 |
foreach ($this->processors as $processor) { |
| 60 |
$record = call_user_func($processor, $record); |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
return $record; |
| 65 |
} |
| 66 |
} |
| 67 |
|