in debug/NicerTrace.py [0:0]
def localtrace_trace_and_count(self, frame, why, arg):
"""
Overriding the default method.
Using hh:mm:ss format for timestamps (instead of secs) as it's more readable when the trace is run for hours
XXX: ideally it would be nice not to repeat the same module name on every line, but when I tried
that I discovered that globaltrace_lt doesn't necessarily frame all the local calls, since
localtrace_trace_and_count may continue printing local calls from an earlier frame w/o
notifying that the context has changed. So we are forced to reprint the module name on each
line to keep at least the incomplete context.
Ideally there should an indication of a frame change before all the local prints
Read the disclaimer in globaltrace_lt that this was tested with py-3.8
"""
if why == "line":
# record the file name and line number of every trace
filename = frame.f_code.co_filename
lineno = frame.f_lineno
key = filename, lineno
self.counts[key] = self.counts.get(key, 0) + 1
basename = os.path.basename(filename)
if self.log_pids:
print(os.getpid(), end=" ")
if self.start_time:
delta_time = trace._time() - self.start_time
delta_time = str(datetime.timedelta(seconds=delta_time)).split(".")[0]
print(delta_time, end=" ")
print(f"{basename}:{lineno:>6}: {trace.linecache.getline(filename, lineno)}", end="")
return self.localtrace