From: NeilBrown Date: Sat, 21 Apr 2012 10:19:14 +0000 (+1000) Subject: Trivial tracing python library X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=43f3b985f39e067fb8efa5a2e604bc9c39c28e29;p=plato.git Trivial tracing python library Allows tracing that can easily be turned on/off Signed-off-by: NeilBrown --- diff --git a/lib/tracing.py b/lib/tracing.py new file mode 100644 index 0000000..1424377 --- /dev/null +++ b/lib/tracing.py @@ -0,0 +1,19 @@ + +# trivial library for including tracing in programs +# It can be turned on with PYTRACE=1 in environment + +import os,time,sys + +tracing = False + +if 'PYTRACE' in os.environ: + if os.environ['PYTRACE']: + tracing = True + +def log(*mesg): + if tracing: + print time.ctime(), + for m in mesg: + print m, + print + sys.stdout.flush()