From: Simon Cross Date: Wed, 7 Sep 2016 19:20:22 +0000 (+0200) Subject: Allow turning on just a single debug point. X-Git-Tag: tabakrolletjie-v1.0.0~199 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=2dc2a3172f0b9a28bb5b688926be1a9e10213512;p=tabakrolletjie.git Allow turning on just a single debug point. --- diff --git a/tabakrolletjie/utils.py b/tabakrolletjie/utils.py index bc5aef2..b605ba1 100644 --- a/tabakrolletjie/utils.py +++ b/tabakrolletjie/utils.py @@ -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