From cb54822dace754e8152497d300ffbd227d693aa7 Mon Sep 17 00:00:00 2001 From: calvin Date: Tue, 17 May 2005 22:46:05 +0000 Subject: [PATCH] trace ignore names git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@2602 e7d03fd6-7b0d-0410-9947-9c21f3af8025 --- linkcheck/log.py | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/linkcheck/log.py b/linkcheck/log.py index 7c960fd9..19980141 100644 --- a/linkcheck/log.py +++ b/linkcheck/log.py @@ -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):