From 8d35ec136d8c216f5ce473fe94b5b4ba84c9314d Mon Sep 17 00:00:00 2001 From: SergeyKovtun Date: Wed, 12 May 2021 10:54:00 +0300 Subject: [PATCH] Up log levels on exceptions --- src/Consumer.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Consumer.php b/src/Consumer.php index e792aab..5810bff 100644 --- a/src/Consumer.php +++ b/src/Consumer.php @@ -199,32 +199,37 @@ public function process(MessageInterface $message, QueueInterface $queue) : void $queue->reject($message); if ($this->logger instanceof LoggerInterface) { - $this->logger->debug(sprintf( + $this->logger->error(sprintf( 'The queue message <%d> cannot be acknowledged (reject executed). %s', $message->getId(), $e->getMessage() - )); + ), [ + 'payload' => $message->getPayload(), + ]); } } catch (UndecodablePayloadExceptionInterface $e) { $queue->reject($message); if ($this->logger instanceof LoggerInterface) { - $this->logger->debug(sprintf( + $this->logger->error(sprintf( 'The queue message <%d> contains undecodable payload (reject executed). %s', $message->getId(), $e->getMessage() - )); + ), [ + 'payload' => $message->getPayload(), + ]); } } catch (InvalidPayloadExceptionInterface $e) { $queue->reject($message); if ($this->logger instanceof LoggerInterface) { - $this->logger->debug(sprintf( + $this->logger->warning(sprintf( 'The queue message <%d> contains invalid payload (reject executed). %s', $message->getId(), $e->getMessage() ), [ 'errors' => $e->getErrors(), + 'payload' => $message->getPayload(), ]); } } catch (Throwable $e) { @@ -237,6 +242,7 @@ public function process(MessageInterface $message, QueueInterface $queue) : void $e->getMessage() ), [ 'exception' => $e, + 'payload' => $message->getPayload(), ]); } }