diff --git a/nvchecker/lib/nicelogger.py b/nvchecker/lib/nicelogger.py index db9d5c8..b4e627b 100644 --- a/nvchecker/lib/nicelogger.py +++ b/nvchecker/lib/nicelogger.py @@ -13,7 +13,7 @@ import logging class TornadoLogFormatter(logging.Formatter): def __init__(self, color, *args, **kwargs): - super().__init__(self, *args, **kwargs) + super().__init__(*args, **kwargs) self._color = color if color: import curses diff --git a/nvchecker/slogconf.py b/nvchecker/slogconf.py index 7d9e07e..b125b45 100644 --- a/nvchecker/slogconf.py +++ b/nvchecker/slogconf.py @@ -64,7 +64,7 @@ class _Logger(logging.Logger): _structlog_dir = os.path.dirname(structlog.__file__) - def findCaller(self, stack_info=False): + def findCaller(self, stack_info=False, stacklevel=1): """ Find the stack frame of the caller so that we can note the source file name, line number and function name. @@ -74,6 +74,12 @@ class _Logger(logging.Logger): #IronPython isn't run with -X:Frames. if f is not None: f = f.f_back + orig_f = f + while f and stacklevel > 1: + f = f.f_back + stacklevel -= 1 + if not f: + f = orig_f rv = "(unknown file)", 0, "(unknown function)", None while hasattr(f, "f_code"): co = f.f_code