From b2e8f4e1a8db52ef4eddaa51b6ce8745b84b24b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Tobias=20de=20Freitas=20Neto?= Date: Sun, 7 Jan 2024 18:03:33 -0400 Subject: [PATCH] =?UTF-8?q?Corrigindo=20par=C3=A2metros=20de=20acordo=20co?= =?UTF-8?q?m=20o=20novo=20construtor=20do=20monolog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/Handlers/DiscordHandler.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/app/Handlers/DiscordHandler.php b/src/app/Handlers/DiscordHandler.php index c32ec41..fd0a444 100644 --- a/src/app/Handlers/DiscordHandler.php +++ b/src/app/Handlers/DiscordHandler.php @@ -10,6 +10,7 @@ use Monolog\Handler\AbstractProcessingHandler; use Monolog\Logger; use Psr\Http\Message\ResponseInterface; use Symfony\Component\HttpFoundation\Response; +use Monolog\LogRecord; class DiscordHandler extends AbstractProcessingHandler { @@ -35,7 +36,7 @@ class DiscordHandler extends AbstractProcessingHandler * @param int $level * @param bool $bubble */ - public function __construct(string $webhook, int $level = Logger::ERROR, bool $bubble = true) + public function __construct(string $webhook, \Monolog\Level $level = \Monolog\Level::ERROR, bool $bubble = true) { $this->webhook = $webhook; $this->client = new Client(); @@ -44,18 +45,18 @@ class DiscordHandler extends AbstractProcessingHandler } /** - * @param array $record + * @param LogRecord $record * @return void * @throws GuzzleException */ - protected function write(array $record): void + protected function write(LogRecord $record): void { if ($this->rateLimitRemaining === 0 && $this->rateLimitReset !== null) { $this->waitUntil($this->rateLimitReset); } try { - $response = $this->send($record); + $response = $this->send($record->toArray()); } catch (ClientException $exception) { $response = $exception->getResponse(); @@ -66,7 +67,7 @@ class DiscordHandler extends AbstractProcessingHandler $retryAfter = $response->getHeaderLine('Retry-After'); $this->wait((int)$retryAfter); - $this->send($record); + $this->send($record->toArray()); } $this->rateLimitRemaining = (int)$response->getHeaderLine('X-RateLimit-Remaining'); @@ -146,4 +147,4 @@ class DiscordHandler extends AbstractProcessingHandler { time_sleep_until($timestamp); } -} \ No newline at end of file +}