Enhanced debug.py: made the mark() function indicate file and line number it was called from. Added if debug: conditions around some other function actions.
- Legacy-Id: 15014
This commit is contained in:
parent
0ef7382f99
commit
493b8daccd
12
debug.py
12
debug.py
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
import sys
|
||||
import time as timeutils
|
||||
import inspect
|
||||
|
@ -84,15 +85,25 @@ def trace(fn): # renamed from 'report' by henrik 16 Jun 2011
|
|||
return fn
|
||||
|
||||
def mark():
|
||||
def show_entry(e):
|
||||
sys.stderr.write(" at %s:L%s %s() %s\n" % e)
|
||||
if debug:
|
||||
indent = ' ' * (_report_indent[0])
|
||||
file, line, func, text = tb.extract_stack(None, 2)[0]
|
||||
parts = file.split(os.sep)
|
||||
name = os.sep.join(parts[-2:])
|
||||
sys.stderr.write("%sMark %s:%s\n" % (indent, name, line))
|
||||
_mark[0] = timeutils.time()
|
||||
|
||||
def lap(s):
|
||||
if debug:
|
||||
clk = timeutils.time()
|
||||
tau = clk - _mark[0]
|
||||
ts = timeutils.strftime("%H:%M:%S", timeutils.localtime(clk))
|
||||
say("%s: %.3fs since mark: %s" % (ts, tau, s))
|
||||
|
||||
def clock(s):
|
||||
if debug:
|
||||
lap(s)
|
||||
_mark[0] = timeutils.time()
|
||||
|
||||
|
@ -205,4 +216,3 @@ def info(name):
|
|||
vtype = eval("type(%s)"%name, frame.f_globals, frame.f_locals)
|
||||
indent = ' ' * (_report_indent[0])
|
||||
sys.stderr.write("%s%s: '%s' (%s)\n" % (indent, name, value, vtype))
|
||||
|
||||
|
|
Loading…
Reference in a new issue