Allow turning on just a single debug point.
authorSimon Cross <hodgestar@gmail.com>
Wed, 7 Sep 2016 19:20:22 +0000 (21:20 +0200)
committerSimon Cross <hodgestar@gmail.com>
Wed, 7 Sep 2016 19:20:22 +0000 (21:20 +0200)
tabakrolletjie/utils.py

index bc5aef2572cf42e3c7ba20146fe2bd80f45974ad..b605ba15f8b6287a82be2e3943c9194fb30c8b9f 100644 (file)
@@ -6,7 +6,7 @@ import time
 from .constants import DEBUG
 
 
-def debug_timer(label):
+def debug_timer(label, debug=False):
     """ A decorator for printing how long a function took if debug is true.
     """
     def debug_inner(f):
@@ -17,7 +17,7 @@ def debug_timer(label):
                 return f(*args, **kw)
             finally:
                 duration = time.time() - start_time
-                if DEBUG:
+                if DEBUG or debug:
                     print "%s [%g seconds]" % (label, duration)
         return wrapper
     return debug_inner