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:
parent
8e8c33b5b8
commit
54305c8254
|
@ -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 = ""):
|
||||||
|
|
Loading…
Reference in New Issue