Skip to content

Commit

Permalink
Up log levels on exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyKovtun committed May 12, 2021
1 parent 0056c0c commit 8d35ec1
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 8d35ec1

Please sign in to comment.