From 08f9aae61ad7200f8e8a0fd33c140eba90837227 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Mon, 30 Dec 2019 17:46:20 +0100 Subject: [PATCH] log.get_caller_pos(): Implement frames > 1 Signed-off-by: Jan Lindemann --- tools/python/jwutils/log.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/python/jwutils/log.py b/tools/python/jwutils/log.py index df40cd2..4f550e6 100644 --- a/tools/python/jwutils/log.py +++ b/tools/python/jwutils/log.py @@ -75,9 +75,8 @@ _prio_colors = { } def get_caller_pos(up = 1): - assert(up == 1) # TODO: implement this - caller_frame = inspect.currentframe().f_back.f_back - return (basename(caller_frame.f_code.co_filename), caller_frame.f_lineno) + caller = inspect.stack()[up+1] + return (basename(caller.filename), caller.lineno) def slog_m(prio, *args, **kwargs): # export if prio > _level: