|
5 | 5 | namespace Ecodev\Felix\Log; |
6 | 6 |
|
7 | 7 | use Ecodev\Felix\Model\CurrentUser; |
8 | | -use Ecodev\Felix\Repository\LogRepository; |
9 | | -use Laminas\Log\Writer\AbstractWriter; |
| 8 | +use Laminas\Log\Processor\ProcessorInterface; |
10 | 9 |
|
11 | | -class DbWriter extends AbstractWriter |
| 10 | +class EventCompleter implements ProcessorInterface |
12 | 11 | { |
13 | | - /** |
14 | | - * @var LogRepository |
15 | | - */ |
16 | | - private $logRepository; |
17 | | - |
18 | 12 | /** |
19 | 13 | * @var string |
20 | 14 | */ |
21 | 15 | private $baseUrl; |
22 | 16 |
|
23 | | - public function __construct(LogRepository $logRepository, string $baseUrl, $options = null) |
| 17 | + public function __construct(string $baseUrl) |
24 | 18 | { |
25 | | - parent::__construct($options); |
26 | | - $this->logRepository = $logRepository; |
27 | 19 | $this->baseUrl = $baseUrl; |
28 | 20 | } |
29 | 21 |
|
30 | 22 | /** |
31 | | - * Write a message to the log |
32 | | - * |
33 | | - * @param array $event log data event |
| 23 | + * Complete a log event with extra data, including stacktrace and any global stuff relevant to the app |
34 | 24 | */ |
35 | | - final protected function doWrite(array $event): void |
36 | | - { |
37 | | - $completedEvent = $this->completeEvent($event); |
38 | | - $this->logRepository->log($completedEvent); |
39 | | - } |
40 | | - |
41 | | - protected function completeEvent(array $event): array |
| 25 | + public function process(array $event): array |
42 | 26 | { |
43 | 27 | $envData = $this->getEnvData(); |
44 | 28 | $event = array_merge($event, $envData); |
@@ -78,6 +62,7 @@ private function getEnvData(): array |
78 | 62 |
|
79 | 63 | $envData = [ |
80 | 64 | 'creator_id' => $user ? $user->getId() : null, |
| 65 | + 'login' => $user ? $user->getLogin() : null, |
81 | 66 | 'url' => $url, |
82 | 67 | 'referer' => $referer, |
83 | 68 | 'request' => json_encode($request, JSON_PRETTY_PRINT), |
|
0 commit comments