logfileco /
logfile-php
| 1 | <?php declare(strict_types=1); |
||||||
| 2 | |||||||
| 3 | namespace Logfile; |
||||||
| 4 | |||||||
| 5 | use Monolog\Logger; |
||||||
| 6 | use Monolog\Handler\AbstractProcessingHandler; |
||||||
| 7 | use Monolog\Formatter\FormatterInterface; |
||||||
| 8 | use Monolog\Formatter\NormalizerFormatter; |
||||||
| 9 | |||||||
| 10 | class MonologHandler extends AbstractProcessingHandler |
||||||
| 11 | { |
||||||
| 12 | protected $logfile; |
||||||
| 13 | |||||||
| 14 | public function __construct(Logfile $logfile, int $level = Logger::DEBUG, bool $bubble = true) |
||||||
| 15 | { |
||||||
| 16 | $this->logfile = $logfile; |
||||||
| 17 | parent::__construct($level, $bubble); |
||||||
| 18 | } |
||||||
| 19 | |||||||
| 20 | protected function getDefaultFormatter(): FormatterInterface |
||||||
| 21 | { |
||||||
| 22 | return new NormalizerFormatter(); |
||||||
| 23 | } |
||||||
| 24 | |||||||
| 25 | protected function write(array $record) |
||||||
| 26 | { |
||||||
| 27 | if (isset($record['context']['exception']) && ($record['context']['exception'] instanceof \Throwable)) { |
||||||
| 28 | $this->logfile->captureException($record['context']['exception']); |
||||||
| 29 | } else { |
||||||
| 30 | $payload = new Payload($record['formatted']['message'], Payload::uuid4()); |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
The method
Logfile\Payload::uuid4() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 31 | $payload->setContext($record['formatted']['context']); |
||||||
| 32 | foreach ($record['formatted']['extra'] as $key => $value) { |
||||||
| 33 | $payload->addTag($key, $value); |
||||||
|
0 ignored issues
–
show
The method
addTag() does not exist on Logfile\Payload.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||||
| 34 | } |
||||||
| 35 | $this->logfile->log($payload); |
||||||
| 36 | } |
||||||
| 37 | } |
||||||
| 38 | } |
||||||
| 39 |