<s> """<STR_LIT>""" <EOL> import sys , os , types , time , string , cStringIO <EOL> try : <EOL> import codecs <EOL> except ImportError : <EOL> codecs = None <EOL> try : <EOL> import thread <EOL> import threading <EOL> except ImportError : <EOL> thread = None <EOL> __author__ = "<STR_LIT>" <EOL> __status__ = "<STR_LIT>" <EOL> __version__ = "<STR_LIT>" <EOL> __date__ = "<STR_LIT>" <EOL> if string . lower ( __file__ [ - <NUM_LIT:4> : ] ) in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> _srcfile = __file__ [ : - <NUM_LIT:4> ] + '<STR_LIT>' <EOL> else : <EOL> _srcfile = __file__ <EOL> _srcfile = os . path . normcase ( _srcfile ) <EOL> def currentframe ( ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> raise '<STR_LIT>' <EOL> except : <EOL> return sys . exc_traceback . tb_frame . f_back <EOL> if hasattr ( sys , '<STR_LIT>' ) : currentframe = sys . _getframe <EOL> _startTime = time . time ( ) <EOL> raiseExceptions = <NUM_LIT:1> <EOL> CRITICAL = <NUM_LIT:50> <EOL> FATAL = CRITICAL <EOL> ERROR = <NUM_LIT> <EOL> WARNING = <NUM_LIT:30> <EOL> WARN = WARNING <EOL> INFO = <NUM_LIT:20> <EOL> DEBUG = <NUM_LIT:10> <EOL> NOTSET = <NUM_LIT:0> <EOL> _levelNames = { <EOL> CRITICAL : '<STR_LIT>' , <EOL> ERROR : '<STR_LIT>' , <EOL> WARNING : '<STR_LIT>' , <EOL> INFO : '<STR_LIT>' , <EOL> DEBUG : '<STR_LIT>' , <EOL> NOTSET : '<STR_LIT>' , <EOL> '<STR_LIT>' : CRITICAL , <EOL> '<STR_LIT>' : ERROR , <EOL> '<STR_LIT>' : WARNING , <EOL> '<STR_LIT>' : WARNING , <EOL> '<STR_LIT>' : INFO , <EOL> '<STR_LIT>' : DEBUG , <EOL> '<STR_LIT>' : NOTSET , <EOL> } <EOL> def getLevelName ( level ) : <EOL> """<STR_LIT>""" <EOL> return _levelNames . get ( level , ( "<STR_LIT>" % level ) ) <EOL> def addLevelName ( level , levelName ) : <EOL> """<STR_LIT>""" <EOL> _acquireLock ( ) <EOL> try : <EOL> _levelNames [ level ] = levelName <EOL> _levelNames [ levelName ] = level <EOL> finally : <EOL> _releaseLock ( ) <EOL> _lock = None <EOL> def _acquireLock ( ) : <EOL> """<STR_LIT>""" <EOL> global _lock <EOL> if ( not _lock ) and thread : <EOL> _lock = threading . RLock ( ) <EOL> if _lock : <EOL> _lock . acquire ( ) <EOL> def _releaseLock ( ) : <EOL> """<STR_LIT>""" <EOL> if _lock : <EOL> _lock . release ( ) <EOL> class LogRecord : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , name , level , pathname , lineno , msg , args , exc_info ) : <EOL> """<STR_LIT>""" <EOL> ct = time . time ( ) <EOL> self . name = name <EOL> self . msg = msg <EOL> if args and ( len ( args ) == <NUM_LIT:1> ) and args [ <NUM_LIT:0> ] and ( type ( args [ <NUM_LIT:0> ] ) == types . DictType ) : <EOL> args = args [ <NUM_LIT:0> ] <EOL> self . args = args <EOL> self . levelname = getLevelName ( level ) <EOL> self . levelno = level <EOL> self . pathname = pathname <EOL> try : <EOL> self . filename = os . path . basename ( pathname ) <EOL> self . module = os . path . splitext ( self . filename ) [ <NUM_LIT:0> ] <EOL> except : <EOL> self . filename = pathname <EOL> self . module = "<STR_LIT>" <EOL> self . exc_info = exc_info <EOL> self . exc_text = None <EOL> self . lineno = lineno <EOL> self . created = ct <EOL> self . msecs = ( ct - long ( ct ) ) * <NUM_LIT:1000> <EOL> self . relativeCreated = ( self . created - _startTime ) * <NUM_LIT:1000> <EOL> if thread : <EOL> self . thread = thread . get_ident ( ) <EOL> else : <EOL> self . thread = None <EOL> if hasattr ( os , '<STR_LIT>' ) : <EOL> self . process = os . getpid ( ) <EOL> else : <EOL> self . process = None <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . name , self . levelno , <EOL> self . pathname , self . lineno , self . msg ) <EOL> def getMessage ( self ) : <EOL> """<STR_LIT>""" <EOL> if not hasattr ( types , "<STR_LIT>" ) : <EOL> msg = str ( self . msg ) <EOL> else : <EOL> try : <EOL> msg = str ( self . msg ) <EOL> except UnicodeError : <EOL> msg = self . msg <EOL> if self . args : <EOL> msg = msg % self . args <EOL> return msg <EOL> def makeLogRecord ( dict ) : <EOL> """<STR_LIT>""" <EOL> rv = LogRecord ( None , None , "<STR_LIT>" , <NUM_LIT:0> , "<STR_LIT>" , ( ) , None ) <EOL> rv . __dict__ . update ( dict ) <EOL> return rv <EOL> class Formatter : <EOL> """<STR_LIT>""" <EOL> converter = time . localtime <EOL> def __init__ ( self , fmt = None , datefmt = None ) : <EOL> """<STR_LIT>""" <EOL> if fmt : <EOL> self . _fmt = fmt <EOL> else : <EOL> self . _fmt = "<STR_LIT>" <EOL> self . datefmt = datefmt <EOL> def formatTime ( self , record , datefmt = None ) : <EOL> """<STR_LIT>""" <EOL> ct = self . converter ( record . created ) <EOL> if datefmt : <EOL> s = time . strftime ( datefmt , ct ) <EOL> else : <EOL> t = time . strftime ( "<STR_LIT>" , ct ) <EOL> s = "<STR_LIT>" % ( t , record . msecs ) <EOL> return s <EOL> def formatException ( self , ei ) : <EOL> """<STR_LIT>""" <EOL> import traceback <EOL> sio = cStringIO . StringIO ( ) <EOL> traceback . print_exception ( ei [ <NUM_LIT:0> ] , ei [ <NUM_LIT:1> ] , ei [ <NUM_LIT:2> ] , None , sio ) <EOL> s = sio . getvalue ( ) <EOL> sio . close ( ) <EOL> if s [ - <NUM_LIT:1> ] == "<STR_LIT:\n>" : <EOL> s = s [ : - <NUM_LIT:1> ] <EOL> return s <EOL> def format ( self , record ) : <EOL> """<STR_LIT>""" <EOL> record . message = record . getMessage ( ) <EOL> if string . find ( self . _fmt , "<STR_LIT>" ) >= <NUM_LIT:0> : <EOL> record . asctime = self . formatTime ( record , self . datefmt ) <EOL> s = self . _fmt % record . __dict__ <EOL> if record . exc_info : <EOL> if not record . exc_text : <EOL> record . exc_text = self . formatException ( record . exc_info ) <EOL> if record . exc_text : <EOL> if s [ - <NUM_LIT:1> ] != "<STR_LIT:\n>" : <EOL> s = s + "<STR_LIT:\n>" <EOL> s = s + record . exc_text <EOL> return s <EOL> _defaultFormatter = Formatter ( ) <EOL> class BufferingFormatter : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , linefmt = None ) : <EOL> """<STR_LIT>""" <EOL> if linefmt : <EOL> self . linefmt = linefmt <EOL> else : <EOL> self . linefmt = _defaultFormatter <EOL> def formatHeader ( self , records ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" <EOL> def formatFooter ( self , records ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" <EOL> def format ( self , records ) : <EOL> """<STR_LIT>""" <EOL> rv = "<STR_LIT>" <EOL> if len ( records ) > <NUM_LIT:0> : <EOL> rv = rv + self . formatHeader ( records ) <EOL> for record in records : <EOL> rv = rv + self . linefmt . format ( record ) <EOL> rv = rv + self . formatFooter ( records ) <EOL> return rv <EOL> class Filter : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , name = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> self . name = name <EOL> self . nlen = len ( name ) <EOL> def filter ( self , record ) : <EOL> """<STR_LIT>""" <EOL> if self . nlen == <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> elif self . name == record . name : <EOL> return <NUM_LIT:1> <EOL> elif string . find ( record . name , self . name , <NUM_LIT:0> , self . nlen ) != <NUM_LIT:0> : <EOL> return <NUM_LIT:0> <EOL> return ( record . name [ self . nlen ] == "<STR_LIT:.>" ) <EOL> class Filterer : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> """<STR_LIT>""" <EOL> self . filters = [ ] <EOL> def addFilter ( self , filter ) : <EOL> """<STR_LIT>""" <EOL> if not ( filter in self . filters ) : <EOL> self . filters . append ( filter ) <EOL> def removeFilter ( self , filter ) : <EOL> """<STR_LIT>""" <EOL> if filter in self . filters : <EOL> self . filters . remove ( filter ) <EOL> def filter ( self , record ) : <EOL> """<STR_LIT>""" <EOL> rv = <NUM_LIT:1> <EOL> for f in self . filters : <EOL> if not f . filter ( record ) : <EOL> rv = <NUM_LIT:0> <EOL> break <EOL> return rv <EOL> _handlers = { } <EOL> class Handler ( Filterer ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , level = NOTSET ) : <EOL> """<STR_LIT>""" <EOL> Filterer . __init__ ( self ) <EOL> self . level = level <EOL> self . formatter = None <EOL> _acquireLock ( ) <EOL> try : <EOL> _handlers [ self ] = <NUM_LIT:1> <EOL> finally : <EOL> _releaseLock ( ) <EOL> self . createLock ( ) <EOL> def createLock ( self ) : <EOL> """<STR_LIT>""" <EOL> if thread : <EOL> self . lock = thread . allocate_lock ( ) <EOL> else : <EOL> self . lock = None <EOL> def acquire ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . lock : <EOL> self . lock . acquire ( ) <EOL> def release ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . lock : <EOL> self . lock . release ( ) <EOL> def setLevel ( self , level ) : <EOL> """<STR_LIT>""" <EOL> self . level = level <EOL> def format ( self , record ) : <EOL> """<STR_LIT>""" <EOL> if self . formatter : <EOL> fmt = self . formatter <EOL> else : <EOL> fmt = _defaultFormatter <EOL> return fmt . format ( record ) <EOL> def emit ( self , record ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError , '<STR_LIT>' '<STR_LIT>' <EOL> def handle ( self , record ) : <EOL> """<STR_LIT>""" <EOL> rv = self . filter ( record ) <EOL> if rv : <EOL> self . acquire ( ) <EOL> try : <EOL> self . emit ( record ) <EOL> finally : <EOL> self . release ( ) <EOL> return rv <EOL> def setFormatter ( self , fmt ) : <EOL> """<STR_LIT>""" <EOL> self . formatter = fmt <EOL> def flush ( self ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def close ( self ) : <EOL> """<STR_LIT>""" <EOL> _acquireLock ( ) <EOL> try : <EOL> del _handlers [ self ] <EOL> finally : <EOL> _releaseLock ( ) <EOL> def handleError ( self , record ) : <EOL> """<STR_LIT>""" <EOL> if raiseExceptions : <EOL> import traceback <EOL> ei = sys . exc_info ( ) <EOL> traceback . print_exception ( ei [ <NUM_LIT:0> ] , ei [ <NUM_LIT:1> ] , ei [ <NUM_LIT:2> ] , None , sys . stderr ) <EOL> del ei <EOL> class StreamHandler ( Handler ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , strm = None ) : <EOL> """<STR_LIT>""" <EOL> Handler . __init__ ( self ) <EOL> if not strm : <EOL> strm = sys . stderr <EOL> self . stream = strm <EOL> self . formatter = None <EOL> def flush ( self ) : <EOL> """<STR_LIT>""" <EOL> self . stream . flush ( ) <EOL> def emit ( self , record ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> msg = self . format ( record ) <EOL> fs = "<STR_LIT>" <EOL> if not hasattr ( types , "<STR_LIT>" ) : <EOL> self . stream . write ( fs % msg ) <EOL> else : <EOL> try : <EOL> self . stream . write ( fs % msg ) <EOL> except UnicodeError : <EOL> self . stream . write ( fs % msg . encode ( "<STR_LIT>" ) ) <EOL> self . flush ( ) <EOL> except : <EOL> self . handleError ( record ) <EOL> class FileHandler ( StreamHandler ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , filename , mode = '<STR_LIT:a>' , encoding = None ) : <EOL> """<STR_LIT>""" <EOL> if codecs is None : <EOL> encoding = None <EOL> if encoding is None : <EOL> stream = open ( filename , mode ) <EOL> else : <EOL> stream = codecs . open ( filename , mode , encoding ) <EOL> StreamHandler . __init__ ( self , stream ) <EOL> self . baseFilename = os . path . abspath ( filename ) <EOL> self . mode = mode <EOL> def close ( self ) : <EOL> """<STR_LIT>""" <EOL> self . flush ( ) <EOL> self . stream . close ( ) <EOL> StreamHandler . close ( self ) <EOL> class PlaceHolder : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , alogger ) : <EOL> """<STR_LIT>""" <EOL> self . loggers = [ alogger ] <EOL> def append ( self , alogger ) : <EOL> """<STR_LIT>""" <EOL> if alogger not in self . loggers : <EOL> self . loggers . append ( alogger ) <EOL> _loggerClass = None <EOL> def setLoggerClass ( klass ) : <EOL> """<STR_LIT>""" <EOL> if klass != Logger : <EOL> if not issubclass ( klass , Logger ) : <EOL> raise TypeError , "<STR_LIT>" + klass . __name__ <EOL> global _loggerClass <EOL> _loggerClass = klass <EOL> def getLoggerClass ( ) : <EOL> """<STR_LIT>""" <EOL> return _loggerClass <EOL> class Manager : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , rootnode ) : <EOL> """<STR_LIT>""" <EOL> self . root = rootnode <EOL> self . disable = <NUM_LIT:0> <EOL> self . emittedNoHandlerWarning = <NUM_LIT:0> <EOL> self . loggerDict = { } <EOL> def getLogger ( self , name ) : <EOL> """<STR_LIT>""" <EOL> rv = None <EOL> _acquireLock ( ) <EOL> try : <EOL> if self . loggerDict . has_key ( name ) : <EOL> rv = self . loggerDict [ name ] <EOL> if isinstance ( rv , PlaceHolder ) : <EOL> ph = rv <EOL> rv = _loggerClass ( name ) <EOL> rv . manager = self <EOL> self . loggerDict [ name ] = rv <EOL> self . _fixupChildren ( ph , rv ) <EOL> self . _fixupParents ( rv ) <EOL> else : <EOL> rv = _loggerClass ( name ) <EOL> rv . manager = self <EOL> self . loggerDict [ name ] = rv <EOL> self . _fixupParents ( rv ) <EOL> finally : <EOL> _releaseLock ( ) <EOL> return rv <EOL> def _fixupParents ( self , alogger ) : <EOL> """<STR_LIT>""" <EOL> name = alogger . name <EOL> i = string . rfind ( name , "<STR_LIT:.>" ) <EOL> rv = None <EOL> while ( i > <NUM_LIT:0> ) and not rv : <EOL> substr = name [ : i ] <EOL> if not self . loggerDict . has_key ( substr ) : <EOL> self . loggerDict [ substr ] = PlaceHolder ( alogger ) <EOL> else : <EOL> obj = self . loggerDict [ substr ] <EOL> if isinstance ( obj , Logger ) : <EOL> rv = obj <EOL> else : <EOL> assert isinstance ( obj , PlaceHolder ) <EOL> obj . append ( alogger ) <EOL> i = string . rfind ( name , "<STR_LIT:.>" , <NUM_LIT:0> , i - <NUM_LIT:1> ) <EOL> if not rv : <EOL> rv = self . root <EOL> alogger . parent = rv <EOL> def _fixupChildren ( self , ph , alogger ) : <EOL> """<STR_LIT>""" <EOL> for c in ph . loggers : <EOL> if string . find ( c . parent . name , alogger . name ) < > <NUM_LIT:0> : <EOL> alogger . parent = c . parent <EOL> c . parent = alogger <EOL> class Logger ( Filterer ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , name , level = NOTSET ) : <EOL> """<STR_LIT>""" <EOL> Filterer . __init__ ( self ) <EOL> self . name = name <EOL> self . level = level <EOL> self . parent = None <EOL> self . propagate = <NUM_LIT:1> <EOL> self . handlers = [ ] <EOL> self . disabled = <NUM_LIT:0> <EOL> def setLevel ( self , level ) : <EOL> """<STR_LIT>""" <EOL> self . level = level <EOL> def debug ( self , msg , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if self . manager . disable >= DEBUG : <EOL> return <EOL> if DEBUG >= self . getEffectiveLevel ( ) : <EOL> apply ( self . _log , ( DEBUG , msg , args ) , kwargs ) <EOL> def info ( self , msg , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if self . manager . disable >= INFO : <EOL> return <EOL> if INFO >= self . getEffectiveLevel ( ) : <EOL> apply ( self . _log , ( INFO , msg , args ) , kwargs ) <EOL> def warning ( self , msg , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if self . manager . disable >= WARNING : <EOL> return <EOL> if self . isEnabledFor ( WARNING ) : <EOL> apply ( self . _log , ( WARNING , msg , args ) , kwargs ) <EOL> warn = warning <EOL> def error ( self , msg , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if self . manager . disable >= ERROR : <EOL> return <EOL> if self . isEnabledFor ( ERROR ) : <EOL> apply ( self . _log , ( ERROR , msg , args ) , kwargs ) <EOL> def exception ( self , msg , * args ) : <EOL> """<STR_LIT>""" <EOL> apply ( self . error , ( msg , ) + args , { '<STR_LIT>' : <NUM_LIT:1> } ) <EOL> def critical ( self , msg , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if self . manager . disable >= CRITICAL : <EOL> return <EOL> if CRITICAL >= self . getEffectiveLevel ( ) : <EOL> apply ( self . _log , ( CRITICAL , msg , args ) , kwargs ) <EOL> fatal = critical <EOL> def log ( self , level , msg , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if type ( level ) != types . IntType : <EOL> if raiseExceptions : <EOL> raise TypeError , "<STR_LIT>" <EOL> else : <EOL> return <EOL> if self . manager . disable >= level : <EOL> return <EOL> if self . isEnabledFor ( level ) : <EOL> apply ( self . _log , ( level , msg , args ) , kwargs ) <EOL> def findCaller ( self ) : <EOL> """<STR_LIT>""" <EOL> f = currentframe ( ) . f_back <EOL> while <NUM_LIT:1> : <EOL> co = f . f_code <EOL> filename = os . path . normcase ( co . co_filename ) <EOL> if filename == _srcfile : <EOL> f = f . f_back <EOL> continue <EOL> return filename , f . f_lineno , co . co_name <EOL> def makeRecord ( self , name , level , fn , lno , msg , args , exc_info ) : <EOL> """<STR_LIT>""" <EOL> return LogRecord ( name , level , fn , lno , msg , args , exc_info ) <EOL> def _log ( self , level , msg , args , exc_info = None ) : <EOL> """<STR_LIT>""" <EOL> if _srcfile : <EOL> fn , lno , func = self . findCaller ( ) <EOL> else : <EOL> fn , lno , func = "<STR_LIT>" , <NUM_LIT:0> , "<STR_LIT>" <EOL> if exc_info : <EOL> if type ( exc_info ) != types . TupleType : <EOL> exc_info = sys . exc_info ( ) <EOL> record = self . makeRecord ( self . name , level , fn , lno , msg , args , exc_info ) <EOL> self . handle ( record ) <EOL> def handle ( self , record ) : <EOL> """<STR_LIT>""" <EOL> if ( not self . disabled ) and self . filter ( record ) : <EOL> self . callHandlers ( record ) <EOL> def addHandler ( self , hdlr ) : <EOL> """<STR_LIT>""" <EOL> if not ( hdlr in self . handlers ) : <EOL> self . handlers . append ( hdlr ) <EOL> def removeHandler ( self , hdlr ) : <EOL> """<STR_LIT>""" <EOL> if hdlr in self . handlers : <EOL> self . handlers . remove ( hdlr ) <EOL> def callHandlers ( self , record ) : <EOL> """<STR_LIT>""" <EOL> c = self <EOL> found = <NUM_LIT:0> <EOL> while c : <EOL> for hdlr in c . handlers : <EOL> found = found + <NUM_LIT:1> <EOL> if record . levelno >= hdlr . level : <EOL> hdlr . handle ( record ) <EOL> if not c . propagate : <EOL> c = None <EOL> else : <EOL> c = c . parent <EOL> if ( found == <NUM_LIT:0> ) and not self . manager . emittedNoHandlerWarning : <EOL> sys . stderr . write ( "<STR_LIT>" <EOL> "<STR_LIT>" % self . name ) <EOL> self . manager . emittedNoHandlerWarning = <NUM_LIT:1> <EOL> def getEffectiveLevel ( self ) : <EOL> """<STR_LIT>""" <EOL> logger = self <EOL> while logger : <EOL> if logger . level : <EOL> return logger . level <EOL> logger = logger . parent <EOL> return NOTSET <EOL> def isEnabledFor ( self , level ) : <EOL> """<STR_LIT>""" <EOL> if self . manager . disable >= level : <EOL> return <NUM_LIT:0> <EOL> return level >= self . getEffectiveLevel ( ) <EOL> class RootLogger ( Logger ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , level ) : <EOL> """<STR_LIT>""" <EOL> Logger . __init__ ( self , "<STR_LIT:root>" , level ) <EOL> _loggerClass = Logger <EOL> root = RootLogger ( WARNING ) <EOL> Logger . root = root <EOL> Logger . manager = Manager ( Logger . root ) <EOL> BASIC_FORMAT = "<STR_LIT>" <EOL> def basicConfig ( ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if len ( root . handlers ) == <NUM_LIT:0> : <EOL> filename = kwargs . get ( "<STR_LIT:filename>" ) <EOL> if filename : <EOL> mode = kwargs . get ( "<STR_LIT>" , '<STR_LIT:a>' ) <EOL> hdlr = FileHandler ( filename , mode ) <EOL> else : <EOL> stream = kwargs . get ( "<STR_LIT>" ) <EOL> hdlr = StreamHandler ( stream ) <EOL> fs = kwargs . get ( "<STR_LIT>" , BASIC_FORMAT ) <EOL> dfs = kwargs . get ( "<STR_LIT>" , None ) <EOL> fmt = Formatter ( fs , dfs ) <EOL> hdlr . setFormatter ( fmt ) <EOL> root . addHandler ( hdlr ) <EOL> level = kwargs . get ( "<STR_LIT>" ) <EOL> if level : <EOL> root . setLevel ( level ) <EOL> def getLogger ( name = None ) : <EOL> """<STR_LIT>""" <EOL> if name : <EOL> return Logger . manager . getLogger ( name ) <EOL> else : <EOL> return root <EOL> def critical ( msg , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if len ( root . handlers ) == <NUM_LIT:0> : <EOL> basicConfig ( ) <EOL> apply ( root . critical , ( msg , ) + args , kwargs ) <EOL> fatal = critical <EOL> def error ( msg , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if len ( root . handlers ) == <NUM_LIT:0> : <EOL> basicConfig ( ) <EOL> apply ( root . error , ( msg , ) + args , kwargs ) <EOL> def exception ( msg , * args ) : <EOL> """<STR_LIT>""" <EOL> apply ( error , ( msg , ) + args , { '<STR_LIT>' : <NUM_LIT:1> } ) <EOL> def warning ( msg , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if len ( root . handlers ) == <NUM_LIT:0> : <EOL> basicConfig ( ) <EOL> apply ( root . warning , ( msg , ) + args , kwargs ) <EOL> warn = warning <EOL> def info ( msg , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if len ( root . handlers ) == <NUM_LIT:0> : <EOL> basicConfig ( ) <EOL> apply ( root . info , ( msg , ) + args , kwargs ) <EOL> def debug ( msg , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if len ( root . handlers ) == <NUM_LIT:0> : <EOL> basicConfig ( ) <EOL> apply ( root . debug , ( msg , ) + args , kwargs ) <EOL> def log ( level , msg , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if len ( root . handlers ) == <NUM_LIT:0> : <EOL> basicConfig ( ) <EOL> apply ( root . log , ( level , msg ) + args , kwargs ) <EOL> def disable ( level ) : <EOL> """<STR_LIT>""" <EOL> root . manager . disable = level <EOL> def shutdown ( ) : <EOL> """<STR_LIT>""" <EOL> for h in _handlers . keys ( ) : <EOL> try : <EOL> h . flush ( ) <EOL> h . close ( ) <EOL> except : <EOL> pass <EOL> try : <EOL> import atexit <EOL> atexit . register ( shutdown ) <EOL> except ImportError : <EOL> def exithook ( status , old_exit = sys . exit ) : <EOL> try : <EOL> shutdown ( ) <EOL> finally : <EOL> old_exit ( status ) <EOL> sys . exit = exithook </s>
