trace ignore names

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@2602 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2005-05-17 22:46:05 +00:00
parent c0d9e56a4d
commit cb54822dac

View file

@ -28,19 +28,20 @@ import inspect
import cStringIO as StringIO
import linecache
import sys
try:
import thread as _thread
except ImportError:
import dummy_thread as _thread
# memory leak debugging
#import gc
#gc.enable()
#gc.set_debug(gc.DEBUG_LEAK)
# call tracing
def trace ():
"""
Start tracing of the current thread (and the current thread only).
"""
sys.settrace(_traceit)
# tracing
_trace_ignore = set()
def trace_ignore (names):
_trace_ignore.update(names)
def _traceit (frame, event, arg):
@ -48,15 +49,24 @@ def _traceit (frame, event, arg):
Print current executed line.
"""
if event == "line":
lineno = frame.f_lineno
filename = frame.f_globals["__file__"]
if filename.endswith(".pyc") or filename.endswith(".pyo"):
filename = filename[:-1]
name = frame.f_globals["__name__"]
line = linecache.getline(filename, lineno)
print "TRACE %s:%d: %s" % (name, lineno, line.rstrip())
if name not in _trace_ignore:
lineno = frame.f_lineno
filename = frame.f_globals["__file__"]
if filename.endswith(".pyc") or filename.endswith(".pyo"):
filename = filename[:-1]
line = linecache.getline(filename, lineno)
print "THREAD(%d) %s:%d: %s" % \
(_thread.get_ident(), name, lineno, line.rstrip())
return _traceit
def trace ():
"""
Start tracing of the current thread (and the current thread only).
"""
sys.settrace(_traceit)
PRINT_LOCALVARS = False
def _stack_format (stack):