From 3a25999372cdb3d288606ad3ad078d77783c2423 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Jolliton?= Date: Sat, 21 Oct 2006 13:35:12 +0000 Subject: [PATCH] Added lib.g_withDebugCall to turn off call debug at runtime. --- rsbac/lib.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/rsbac/lib.py b/rsbac/lib.py index 4de9489..fbdac14 100644 --- a/rsbac/lib.py +++ b/rsbac/lib.py @@ -31,8 +31,13 @@ g_checkArgumentCount = True # For debugging purpose. When a function is called, print its name and # all its arguments. Be careful, because it can coredump when printing -# non initialized strings. -g_debug = False +# non initialized strings. See also g_withDebugCall. +g_debug = True + +# This variable can be updated at runtime. If True (and if module was +# loaded while g_debug was True) then print information as described +# in the comment on the variable g_debug. +g_withDebugCall = True import sys @@ -57,10 +62,12 @@ def debugVar( var ) : def debugCall( f ) : def fun( *args ) : - print '[**] %s(%s) =>' % ( f.__name__ , ', '.join( map( debugVar , args ) ) ) , - sys.stdout.flush() + if g_withDebugCall : + print '[**] %s(%s) =>' % ( f.__name__ , ', '.join( map( debugVar , args ) ) ) , + sys.stdout.flush() r = f( *args ) - print debugVar( r ) + if g_withDebugCall : + print debugVar( r ) return r fun.__name__ = '[dbg]' + f.__name__ return fun -- 2.11.0