# 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
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