mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-27 19:20:30 +00:00
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:
parent
c0d9e56a4d
commit
cb54822dac
1 changed files with 23 additions and 13 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue