1 | <?php declare(strict_types=1); |
||
13 | final class LogglyLogger extends AbstractLogger |
||
14 | { |
||
15 | /** |
||
16 | * @var Client |
||
17 | */ |
||
18 | private $httpClient; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | private $token; |
||
24 | |||
25 | /** |
||
26 | * Logging levels PSR-3 LogLevel enum |
||
27 | * |
||
28 | * @var array $levels Logging levels |
||
29 | */ |
||
30 | const LOG_LEVELS = [ |
||
31 | LogLevel::DEBUG => 'DEBUG', |
||
32 | LogLevel::INFO => 'INFO', |
||
33 | LogLevel::NOTICE => 'NOTICE', |
||
34 | LogLevel::WARNING => 'WARNING', |
||
35 | LogLevel::ERROR => 'ERROR', |
||
36 | LogLevel::CRITICAL => 'CRITICAL', |
||
37 | LogLevel::ALERT => 'ALERT', |
||
38 | LogLevel::EMERGENCY => 'EMERGENCY', |
||
39 | ]; |
||
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 = []) |
|
74 | |||
75 | 12 | private function format($level, $message, array $context): string |
|
93 | |||
94 | 12 | private function send(string $data) |
|
106 | |||
107 | /** |
||
108 | * @param string $message |
||
109 | * @param array $context |
||
110 | * @return string |
||
111 | * |
||
112 | * Method copied from: https://github.com/Seldaek/monolog/blob/6e6586257d9fb231bf039563632e626cdef594e5/src/Monolog/Processor/PsrLogMessageProcessor.php |
||
113 | */ |
||
114 | 12 | private function processPlaceHolders(string $message, array $context): string |
|
133 | |||
134 | 12 | private function normalizeContext(array $context): array |
|
149 | } |
||
150 |