Dynamic log level on LookupException
This commit is contained in:
@ -4,6 +4,15 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Nsq\Exception;
|
namespace Nsq\Exception;
|
||||||
|
|
||||||
|
use Psr\Log\LogLevel;
|
||||||
|
|
||||||
final class LookupException extends NsqException
|
final class LookupException extends NsqException
|
||||||
{
|
{
|
||||||
|
public function level(): string
|
||||||
|
{
|
||||||
|
return match ($this->getMessage()) {
|
||||||
|
'TOPIC_NOT_FOUND' => LogLevel::DEBUG,
|
||||||
|
default => LogLevel::WARNING,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ final class Lookup
|
|||||||
try {
|
try {
|
||||||
return Lookup\Response::fromJson($buffer);
|
return Lookup\Response::fromJson($buffer);
|
||||||
} catch (LookupException $e) {
|
} catch (LookupException $e) {
|
||||||
$logger->warning($e->getMessage());
|
$logger->log($e->level(), $uri.' '.$e->getMessage());
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user