diff --git a/slic/utils/debug.py b/slic/utils/debug.py index c895a28d7..b28399af6 100644 --- a/slic/utils/debug.py +++ b/slic/utils/debug.py @@ -16,7 +16,7 @@ class Traceable: combined = ", ".join(combined) line = f"{cls_name}({combined})" - log.trace(f"creating: {line}") + log.trace(f"creating: {line}", stacklevel=2) # increase stacklevel by 1 to skip Registry return super().__new__(cls) diff --git a/slic/utils/logcfg.py b/slic/utils/logcfg.py index 7d34da8cf..a2908201e 100644 --- a/slic/utils/logcfg.py +++ b/slic/utils/logcfg.py @@ -27,8 +27,7 @@ def add_log_Level(logger, level_name, level_value, func_name=None, color=None): def log_func_for_class(self, *args, **kwargs): if sys.version_info >= (3,8): #TODO: how to do this for <=3.7 stacklevel = kwargs.get("stacklevel", 1) -# stacklevel += 3 # Traceable with stacklevel=1: 0 logcfg => 1 debug => 2 registry => 3 actual location - stacklevel += 2 # import logging: 0 logcfg (log_func_for_class) => 1 logcfg (import_with_log) => 2 actual location + stacklevel += 2 # 0 here => 1 call to log.trace() => 2 actual location kwargs["stacklevel"] = stacklevel self.log(level_value, *args, **kwargs)