<s> """<STR_LIT>""" <EOL> DEBUG = <NUM_LIT:1> <EOL> INFO = <NUM_LIT:2> <EOL> WARN = <NUM_LIT:3> <EOL> ERROR = <NUM_LIT:4> <EOL> FATAL = <NUM_LIT:5> <EOL> import sys <EOL> class Log : <EOL> def __init__ ( self , threshold = WARN ) : <EOL> self . threshold = threshold <EOL> def _log ( self , level , msg , args ) : <EOL> if level >= self . threshold : <EOL> if not args : <EOL> print msg <EOL> else : <EOL> print msg % args <EOL> sys . stdout . flush ( ) <EOL> def log ( self , level , msg , * args ) : <EOL> self . _log ( level , msg , args ) <EOL> def debug ( self , msg , * args ) : <EOL> self . _log ( DEBUG , msg , args ) <EOL> def info ( self , msg , * args ) : <EOL> self . _log ( INFO , msg , args ) <EOL> def warn ( self , msg , * args ) : <EOL> self . _log ( WARN , msg , args ) <EOL> def error ( self , msg , * args ) : <EOL> self . _log ( ERROR , msg , args ) <EOL> def fatal ( self , msg , * args ) : <EOL> self . _log ( FATAL , msg , args ) <EOL> _global_log = Log ( ) <EOL> log = _global_log . log <EOL> debug = _global_log . debug <EOL> info = _global_log . info <EOL> warn = _global_log . warn <EOL> error = _global_log . error <EOL> fatal = _global_log . fatal <EOL> def set_threshold ( level ) : <EOL> old = _global_log . threshold <EOL> _global_log . threshold = level <EOL> return old <EOL> def set_verbosity ( v ) : <EOL> if v <= <NUM_LIT:0> : <EOL> set_threshold ( WARN ) <EOL> elif v == <NUM_LIT:1> : <EOL> set_threshold ( INFO ) <EOL> elif v >= <NUM_LIT:2> : <EOL> set_threshold ( DEBUG ) </s>
