1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-12-26 01:50:31 +00:00

Fixed logging of exception in debug_or_exception handler for python version <3.8

This commit is contained in:
Ozzie Isaacs 2021-01-12 20:51:49 +01:00
parent e5f754ed0e
commit 9acea8adf4

View File

@ -44,10 +44,22 @@ logging.addLevelName(logging.CRITICAL, "CRIT")
class _Logger(logging.Logger): class _Logger(logging.Logger):
def debug_or_exception(self, message, *args, **kwargs): def debug_or_exception(self, message, *args, **kwargs):
if sys.version_info > (3, 7):
if is_debug_enabled(): if is_debug_enabled():
self.exception(message, stacklevel=2, *args, **kwargs) self.exception(message, stacklevel=2, *args, **kwargs)
else: else:
self.error(message, stacklevel=2, *args, **kwargs) self.error(message, stacklevel=2, *args, **kwargs)
elif sys.version_info > (3, 0):
if is_debug_enabled():
self.exception(message, stack_info=True, *args, **kwargs)
else:
self.error(message, *args, **kwargs)
else:
if is_debug_enabled():
self.exception(message, *args, **kwargs)
else:
self.error(message, *args, **kwargs)
def debug_no_auth(self, message, *args, **kwargs): def debug_no_auth(self, message, *args, **kwargs):
if message.startswith("send: AUTH"): if message.startswith("send: AUTH"):