print exc_info only on debug

This commit is contained in:
Florian Bezannier
2021-05-03 20:09:09 +02:00
committed by Florian BEZANNIER
parent 89e60083d4
commit 8209af5726
+7 -2
View File
@@ -6,12 +6,17 @@ logging.addLevelName(DEBUG_LEVELV_NUM, "DEBUGV")
class CustomLogger(logging.Logger):
# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments,unused-argument,arguments-differ
def _log(self, level, msg, args, exc_info=None, extra=None, stack_info=False, exc_info_debug=False, **kwargs):
if exc_info_debug and self.isEnabledFor(logging.DEBUG):
exc_info = True
super()._log(level, msg, args, exc_info, extra, stack_info)
def __new_style_log(self, level, msg, args, exc_info=None, extra=None, stack_info=False, **kwargs):
if kwargs.pop('style', "%") == "{": # optional
msg = msg.format(*args)
args = []
super()._log(level, msg, args, exc_info, extra, stack_info)
self._log(level, msg, args, exc_info, extra, stack_info)
def debugv(self, msg, *args, **kwargs):
if self.isEnabledFor(DEBUG_LEVELV_NUM):