diff --git a/src/Exception/LookupException.php b/src/Exception/LookupException.php index 998dcfa..17085e8 100644 --- a/src/Exception/LookupException.php +++ b/src/Exception/LookupException.php @@ -4,6 +4,15 @@ declare(strict_types=1); namespace Nsq\Exception; +use Psr\Log\LogLevel; + final class LookupException extends NsqException { + public function level(): string + { + return match ($this->getMessage()) { + 'TOPIC_NOT_FOUND' => LogLevel::DEBUG, + default => LogLevel::WARNING, + }; + } } diff --git a/src/Lookup.php b/src/Lookup.php index 1d5019e..4bd6848 100644 --- a/src/Lookup.php +++ b/src/Lookup.php @@ -57,7 +57,7 @@ final class Lookup try { return Lookup\Response::fromJson($buffer); } catch (LookupException $e) { - $logger->warning($e->getMessage()); + $logger->log($e->level(), $uri.' '.$e->getMessage()); return null; }