From 43f3b985f39e067fb8efa5a2e604bc9c39c28e29 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sat, 21 Apr 2012 20:19:14 +1000 Subject: [PATCH] Trivial tracing python library Allows tracing that can easily be turned on/off Signed-off-by: NeilBrown --- lib/tracing.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/tracing.py 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() -- 2.39.5