1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Honeybadger\HoneybadgerLaravel; |
4
|
|
|
|
5
|
|
|
use Monolog\Logger; |
6
|
|
|
use Honeybadger\Contracts\Reporter; |
7
|
|
|
use Monolog\Formatter\LineFormatter; |
8
|
|
|
use Monolog\Formatter\FormatterInterface; |
9
|
|
|
use Monolog\Handler\AbstractProcessingHandler; |
10
|
|
|
|
11
|
|
|
class LogHandler extends AbstractProcessingHandler |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @var \Honeybadger\Contracts\Reporter |
15
|
|
|
*/ |
16
|
|
|
protected $honeybadger; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @param \Honeybadger\Contracts\Reporter $honeybadger |
20
|
|
|
* @param int $level |
21
|
|
|
* @param bool $bubble |
22
|
|
|
*/ |
23
|
|
|
public function __construct(Reporter $honeybadger, int $level = Logger::DEBUG, bool $bubble = true) |
24
|
|
|
{ |
25
|
|
|
parent::__construct($level, $bubble); |
26
|
|
|
|
27
|
|
|
$this->honeybadger = $honeybadger; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* {@inheritdoc} |
32
|
|
|
*/ |
33
|
|
|
protected function write(array $record) |
34
|
|
|
{ |
35
|
|
|
$this->honeybadger->rawNotification(function ($config) use ($record) { |
|
|
|
|
36
|
|
|
return [ |
37
|
|
|
'notifier' => array_merge($config['notifier'], ['name' => 'Honeybadger Log Handler']), |
38
|
|
|
'error' => [ |
39
|
|
|
'class' => $record['message'], |
40
|
|
|
'message' => $record['formatted'], |
41
|
|
|
'tags' => [ |
42
|
|
|
'log', |
43
|
|
|
sprintf('%s.%s', $record['channel'], $record['level_name']), |
44
|
|
|
], |
45
|
|
|
'fingerprint' => md5($record['formatted']), |
46
|
|
|
], |
47
|
|
|
'request' => [ |
48
|
|
|
'context' => [ |
49
|
|
|
'context' => $record['context'], |
50
|
|
|
'level_name' => $record['level_name'], |
51
|
|
|
'log_channel' => $record['channel'], |
52
|
|
|
'message' => $record['message'], |
53
|
|
|
], |
54
|
|
|
], |
55
|
|
|
]; |
56
|
|
|
}); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* {@inheritdoc} |
61
|
|
|
*/ |
62
|
|
|
public function getFormatter() : FormatterInterface |
63
|
|
|
{ |
64
|
|
|
return new LineFormatter('[%datetime%] %channel%.%level_name%: %message%'); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
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.