1 | <?php declare(strict_types=1); |
||
13 | final class LogglyLogger extends AbstractLogger |
||
14 | { |
||
15 | /** |
||
16 | * Logging levels PSR-3 LogLevel enum |
||
17 | * |
||
18 | * @var array $levels Logging levels |
||
19 | */ |
||
20 | const LOG_LEVELS = [ |
||
21 | LogLevel::DEBUG => 'DEBUG', |
||
22 | LogLevel::INFO => 'INFO', |
||
23 | LogLevel::NOTICE => 'NOTICE', |
||
24 | LogLevel::WARNING => 'WARNING', |
||
25 | LogLevel::ERROR => 'ERROR', |
||
26 | LogLevel::CRITICAL => 'CRITICAL', |
||
27 | LogLevel::ALERT => 'ALERT', |
||
28 | LogLevel::EMERGENCY => 'EMERGENCY', |
||
29 | ]; |
||
30 | |||
31 | /** |
||
32 | * @var Client |
||
33 | */ |
||
34 | private $httpClient; |
||
35 | |||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | private $token; |
||
40 | |||
41 | 2 | public static function create(LoopInterface $loop, string $token): self |
|
51 | |||
52 | 12 | public static function createFromHttpClient(Client $httpClient, string $token): self |
|
56 | |||
57 | 14 | private function __construct(Client $httpClient, string $token) |
|
62 | |||
63 | 13 | public function log($level, $message, array $context = []) |
|
75 | |||
76 | 12 | protected function format($level, $message, array $context): string |
|
94 | |||
95 | /** |
||
96 | * @param string $message |
||
97 | * @param array $context |
||
98 | * @return string |
||
99 | * |
||
100 | * Method copied from: https://github.com/Seldaek/monolog/blob/6e6586257d9fb231bf039563632e626cdef594e5/src/Monolog/Processor/PsrLogMessageProcessor.php |
||
101 | */ |
||
102 | 12 | private function processPlaceHolders(string $message, array $context): string |
|
121 | |||
122 | 12 | private function normalizeContext(array $context): array |
|
137 | |||
138 | 12 | protected function send(string $data) |
|
150 | } |
||
151 |