Skip to content

Commit c5709e3

Browse files
committed
Added called-from information to the debug.trace output.
- Legacy-Id: 12058
1 parent 613363c commit c5709e3

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

debug.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,20 @@ def wrap(fn, *params,**kwargs):
5454
call = wrap.callcount = wrap.callcount + 1
5555

5656
indent = ' ' * _report_indent[0]
57+
fr = tb.format_stack()[-3].strip()[4:]
58+
fi, co = [ l.strip() for l in fr.splitlines()[:2] ]
5759
fc = "%s.%s(%s)" % (fn.__module__, fn.__name__, ', '.join(
5860
[fix(repr(a)) for a in params] +
5961
["%s = %s" % (a, fix(repr(b))) for a,b in kwargs.items()]
6062
))
6163

6264
if debug:
63-
sys.stderr.write("%s* %s [#%s]\n" % (indent, fc, call))
65+
sys.stderr.write("%s* From %s:\n%s | %s\n%s => %s [#%s]\n" % (indent, fi, indent, co, indent, fc, call))
6466
_report_indent[0] += increment
6567
ret = fn(*params,**kwargs)
6668
_report_indent[0] -= increment
6769
if debug:
68-
sys.stderr.write("%s %s [#%s] ==> %s\n" % (indent, fc, call, fix(repr(ret))))
70+
sys.stderr.write("%s %s [#%s] ==> %s\n" % (indent, fc, call, fix(repr(ret))))
6971

7072
return ret
7173
wrap.callcount = 0

0 commit comments

Comments
 (0)