From 54305c825482321e92d405571148d7bd6db62bbc Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 17 Feb 2010 21:15:33 +0100 Subject: [PATCH] Add basic support for filtering in dbg() to reduce the noise if someone only cares about a few classes/methods --- terminatorlib/util.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/terminatorlib/util.py b/terminatorlib/util.py index 034c05f5..5bba43d6 100755 --- a/terminatorlib/util.py +++ b/terminatorlib/util.py @@ -33,6 +33,10 @@ import inspect DEBUG = False # set this to true to additionally list filenames in debugging 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 = ""): """Print a message if debugging is enabled""" @@ -52,6 +56,10 @@ def dbg(log = ""): extra = " (%s:%s)" % (filename, line) else: 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) def err(log = ""):