Add basic support for filtering in dbg() to reduce the noise if someone only cares about a few classes/methods

This commit is contained in:
Chris Jones 2010-02-17 21:15:33 +01:00
parent 8e8c33b5b8
commit 54305c8254
1 changed files with 8 additions and 0 deletions

View File

@ -33,6 +33,10 @@ import inspect
DEBUG = False DEBUG = False
# set this to true to additionally list filenames in debugging # set this to true to additionally list filenames in debugging
DEBUGFILES = False DEBUGFILES = False
# list of classes to show debugging for. empty list means show all classes
DEBUGCLASSES = []
# list of methods to show debugging for. empty list means show all methods
DEBUGMETHODS = []
def dbg(log = ""): def dbg(log = ""):
"""Print a message if debugging is enabled""" """Print a message if debugging is enabled"""
@ -52,6 +56,10 @@ def dbg(log = ""):
extra = " (%s:%s)" % (filename, line) extra = " (%s:%s)" % (filename, line)
else: else:
extra = "" extra = ""
if DEBUGCLASSES != [] and classname not in DEBUGCLASSES:
return
if DEBUGMETHODS != [] and method not in DEBUGMETHODS:
return
print >> sys.stderr, "%s::%s: %s%s" % (classname, method, log, extra) print >> sys.stderr, "%s::%s: %s%s" % (classname, method, log, extra)
def err(log = ""): def err(log = ""):