Additional changes to the output of @debug.trace

- Legacy-Id: 12060
This commit is contained in:
Henrik Levkowetz 2016-09-30 10:32:16 +00:00
parent 49ac744b1c
commit 3327240c47

View file

@ -54,20 +54,22 @@ def trace(fn): # renamed from 'report' by henrik 16 Jun 2011
call = wrap.callcount = wrap.callcount + 1
indent = ' ' * _report_indent[0]
fr = tb.format_stack()[-3].strip()[4:]
fi, co = [ l.strip() for l in fr.splitlines()[:2] ]
fc = "%s.%s(%s)" % (fn.__module__, fn.__name__, ', '.join(
fr = tb.format_stack()[-3].strip()[4:] # call from
fi, co = [ l.strip() for l in fr.splitlines()[:2] ] # file info, code
fu = "%s.%s()" % (fn.__module__, fn.__name__) # function name
fc = "%s(%s)" % (fn.__name__, ', '.join( # function call
[fix(repr(a)) for a in params] +
["%s = %s" % (a, fix(repr(b))) for a,b in kwargs.items()]
))
if debug:
sys.stderr.write("%s* From %s:\n%s | %s\n%s => %s [#%s]\n" % (indent, fi, indent, co, indent, fc, call))
sys.stderr.write("\n%s From %s:\n%s | %s\n%s %s\n%s* %s [#%s]\n" %
(indent, fi, indent, co, indent, fu, indent, fc, call))
_report_indent[0] += increment
ret = fn(*params,**kwargs)
_report_indent[0] -= increment
if debug:
sys.stderr.write("%s %s [#%s] ==> %s\n" % (indent, fc, call, fix(repr(ret))))
sys.stderr.write("%s %s [#%s] ==> %s\n" % (indent, fc, call, fix(repr(ret))))
return ret
wrap.callcount = 0