1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-11-28 04:19:59 +00:00

feat: base is_debug on effective level vs root log level

This commit is contained in:
Daniel Edwards 2024-03-19 11:05:04 +11:00
parent becb84a73d
commit 28c810b514
No known key found for this signature in database
GPG Key ID: 9F6FA6ECD4DF3A35

View File

@ -43,13 +43,14 @@ logging.addLevelName(logging.CRITICAL, "CRIT")
class _Logger(logging.Logger):
def error_or_exception(self, message, stacklevel=2, *args, **kwargs):
is_debug = self.getEffectiveLevel() <= logging.DEBUG
if sys.version_info > (3, 7):
if is_debug_enabled():
if is_debug:
self.exception(message, stacklevel=stacklevel, *args, **kwargs)
else:
self.error(message, stacklevel=stacklevel, *args, **kwargs)
else:
if is_debug_enabled():
if is_debug:
self.exception(message, stack_info=True, *args, **kwargs)
else:
self.error(message, *args, **kwargs)