Skip to content

Commit

Permalink
Update utils.trace
Browse files Browse the repository at this point in the history
The trace call now include the filename from where the call was
made as well as the qualname for the function/method being called
so you can see from the logs what class the call is from
  • Loading branch information
hemna committed Nov 14, 2024
1 parent 03ce5a3 commit c3df974
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions aprsd/utils/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def trace(*dec_args, **dec_kwargs):

def _decorator(f):

func_name = f.__name__
func_name = f.__qualname__
func_file = "/".join(f.__code__.co_filename.split("/")[-4:])

@functools.wraps(f)
def trace_logging_wrapper(*args, **kwargs):
Expand All @@ -46,10 +47,11 @@ def trace_logging_wrapper(*args, **kwargs):

if pass_filter:
logger.debug(
"==> %(func)s: call %(all_args)r",
"==> %(func)s: call %(all_args)r file: %(file)s",
{
"func": func_name,
"all_args": str(all_args),
"file": func_file,
},
)

Expand Down

0 comments on commit c3df974

Please sign in to comment.