Improved test logging with frame inspection
This commit is contained in:
@@ -6,6 +6,16 @@ import sys
|
||||
import shlex
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
import inspect
|
||||
|
||||
def get_caller() -> str:
|
||||
frame = inspect.currentframe()
|
||||
caller_frame = frame.f_back.f_back
|
||||
frame_info = inspect.getframeinfo(caller_frame)
|
||||
ret = f"{frame_info.filename}:{frame_info.lineno}::{frame_info.function}"
|
||||
return ret
|
||||
|
||||
|
||||
class Cli:
|
||||
def __init__(self) -> None:
|
||||
self.parser = create_parser(prog="clan")
|
||||
@@ -13,6 +23,7 @@ class Cli:
|
||||
def run(self, args: list[str]) -> argparse.Namespace:
|
||||
cmd = shlex.join(["clan"] + args)
|
||||
log.debug(f"Command: {cmd}")
|
||||
log.debug(f"Caller {get_caller()}")
|
||||
parsed = self.parser.parse_args(args)
|
||||
if hasattr(parsed, "func"):
|
||||
parsed.func(parsed)
|
||||
|
||||
Reference in New Issue
Block a user