When a connection is unexpectedly closed, aiormq logs this with the log.exception function (link), breaking parts of the structlog logging library.
The structlog ExceptionDictTransformer exception transformer expects this function to only get called from an exception handler. When called outside an exception handler, it raises an exception itself when it is passed the results of sys.exc_info() ((None, None, None)), as it tries to access __name__ of the exc_type.
While I think it is a bug in the structlog library that this leads to an exception during logging (issue) I think it would be nice to change the log.exception into log.error to avoid triggering this bug or potentially other bugs in log formatters that expect exception to only be used while handling an exception.
When a connection is unexpectedly closed, aiormq logs this with the
log.exception
function (link), breaking parts of the structlog logging library.The structlog
ExceptionDictTransformer
exception transformer expects this function to only get called from an exception handler. When called outside an exception handler, it raises an exception itself when it is passed the results ofsys.exc_info()
((None, None, None)
), as it tries to access__name__
of theexc_type
.While I think it is a bug in the structlog library that this leads to an exception during logging (issue) I think it would be nice to change the
log.exception
intolog.error
to avoid triggering this bug or potentially other bugs in log formatters that expectexception
to only be used while handling an exception.