feat: base is_debug on effective level vs root log level
This commit is contained in:
parent
becb84a73d
commit
28c810b514
|
@ -43,13 +43,14 @@ logging.addLevelName(logging.CRITICAL, "CRIT")
|
||||||
class _Logger(logging.Logger):
|
class _Logger(logging.Logger):
|
||||||
|
|
||||||
def error_or_exception(self, message, stacklevel=2, *args, **kwargs):
|
def error_or_exception(self, message, stacklevel=2, *args, **kwargs):
|
||||||
|
is_debug = self.getEffectiveLevel() <= logging.DEBUG
|
||||||
if sys.version_info > (3, 7):
|
if sys.version_info > (3, 7):
|
||||||
if is_debug_enabled():
|
if is_debug:
|
||||||
self.exception(message, stacklevel=stacklevel, *args, **kwargs)
|
self.exception(message, stacklevel=stacklevel, *args, **kwargs)
|
||||||
else:
|
else:
|
||||||
self.error(message, stacklevel=stacklevel, *args, **kwargs)
|
self.error(message, stacklevel=stacklevel, *args, **kwargs)
|
||||||
else:
|
else:
|
||||||
if is_debug_enabled():
|
if is_debug:
|
||||||
self.exception(message, stack_info=True, *args, **kwargs)
|
self.exception(message, stack_info=True, *args, **kwargs)
|
||||||
else:
|
else:
|
||||||
self.error(message, *args, **kwargs)
|
self.error(message, *args, **kwargs)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user