<s> """<STR_LIT>""" <EOL> import sys <EOL> from twisted . python import log <EOL> DEBUG = <NUM_LIT:5> <EOL> WARNING = <NUM_LIT:4> <EOL> INFO = <NUM_LIT:3> <EOL> ERROR = <NUM_LIT:2> <EOL> CRITICAL = <NUM_LIT:1> <EOL> levels = { "<STR_LIT>" : <NUM_LIT:5> , "<STR_LIT>" : <NUM_LIT:4> , "<STR_LIT:info>" : <NUM_LIT:3> , "<STR_LIT:error>" : <NUM_LIT:2> , "<STR_LIT>" : <NUM_LIT:1> } <EOL> class FileLogObserver ( log . FileLogObserver ) : <EOL> def __init__ ( self , f = None , level = "<STR_LIT:info>" , default = DEBUG ) : <EOL> log . FileLogObserver . __init__ ( self , f or sys . stdout ) <EOL> self . level = levels [ level ] <EOL> self . default = default <EOL> def emit ( self , eventDict ) : <EOL> ll = eventDict . get ( '<STR_LIT>' , self . default ) <EOL> if eventDict [ '<STR_LIT>' ] or '<STR_LIT>' in eventDict or self . level >= ll : <EOL> log . FileLogObserver . emit ( self , eventDict ) <EOL> class Logger ( object ) : <EOL> def __init__ ( self , ** kwargs ) : <EOL> self . kwargs = kwargs <EOL> def msg ( self , message , ** kw ) : <EOL> kw . update ( self . kwargs ) <EOL> if '<STR_LIT>' in kw and not isinstance ( kw [ '<STR_LIT>' ] , str ) : <EOL> kw [ '<STR_LIT>' ] = kw [ '<STR_LIT>' ] . __class__ . __name__ <EOL> log . msg ( message , ** kw ) <EOL> def info ( self , message , ** kw ) : <EOL> kw [ '<STR_LIT>' ] = INFO <EOL> self . msg ( "<STR_LIT>" % message , ** kw ) <EOL> def debug ( self , message , ** kw ) : <EOL> kw [ '<STR_LIT>' ] = DEBUG <EOL> self . msg ( "<STR_LIT>" % message , ** kw ) <EOL> def warning ( self , message , ** kw ) : <EOL> kw [ '<STR_LIT>' ] = WARNING <EOL> self . msg ( "<STR_LIT>" % message , ** kw ) <EOL> def error ( self , message , ** kw ) : <EOL> kw [ '<STR_LIT>' ] = ERROR <EOL> self . msg ( "<STR_LIT>" % message , ** kw ) <EOL> def critical ( self , message , ** kw ) : <EOL> kw [ '<STR_LIT>' ] = CRITICAL <EOL> self . msg ( "<STR_LIT>" % message , ** kw ) <EOL> try : <EOL> theLogger <EOL> except NameError : <EOL> theLogger = Logger ( ) <EOL> msg = theLogger . msg <EOL> info = theLogger . info <EOL> debug = theLogger . debug <EOL> warning = theLogger . warning <EOL> error = theLogger . error <EOL> critical = theLogger . critical </s>
