Skip to content

Commit

Permalink
fix potential log excheptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Lancetnik committed May 22, 2023
1 parent 0877ceb commit 921248b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion propan/__about__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Simple and fast framework to create message brokers based microservices"""

__version__ = "0.1.1.3"
__version__ = "0.1.1.4"
4 changes: 2 additions & 2 deletions propan/brokers/model/broker_usecase.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,15 @@ async def wrapper(message: PropanMessage) -> T:
log_context = self._get_log_context(message=message, **broker_args)

with context.scope("log_context", log_context):
self._log("Received")
self._log("Received", extra=log_context)

try:
r = await func(message)
except Exception as e:
self._log(repr(e), logging.ERROR)
raise e
else:
self._log("Processed")
self._log("Processed", extra=log_context)
return r

return wrapper
Expand Down
3 changes: 2 additions & 1 deletion propan/brokers/rabbit/rabbit_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ async def _connect(
self._channel = await connection.channel()

if max_consumers:
self._log(f"Set max consumers to {max_consumers}")
c = self._get_log_context(None, RabbitQueue(""), RabbitExchange(""))
self._log(f"Set max consumers to {max_consumers}", extra=c)
await self._channel.set_qos(prefetch_count=int(self._max_consumers))

return connection
Expand Down

0 comments on commit 921248b

Please sign in to comment.