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