Skip to content

Commit

Permalink
Merge pull request #1 from autorusltd/develop/upLogLevelsOnExceptions
Browse files Browse the repository at this point in the history
Up log levels on exceptions
  • Loading branch information
MartinDugin authored May 12, 2021
2 parents 0056c0c + 8d35ec1 commit 714e195
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/Consumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -237,6 +242,7 @@ public function process(MessageInterface $message, QueueInterface $queue) : void
$e->getMessage()
), [
'exception' => $e,
'payload' => $message->getPayload(),
]);
}
}
Expand Down

0 comments on commit 714e195

Please sign in to comment.