From 28c810b514ffcbbd29a2940aec079be637b57b13 Mon Sep 17 00:00:00 2001 From: Daniel Edwards Date: Tue, 19 Mar 2024 11:05:04 +1100 Subject: [PATCH] feat: base is_debug on effective level vs root log level --- cps/logger.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cps/logger.py b/cps/logger.py index 74f7fb39..9aa076d4 100644 --- a/cps/logger.py +++ b/cps/logger.py @@ -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)