<s> """<STR_LIT>""" <EOL> __docformat__ = "<STR_LIT>" <EOL> import logging <EOL> import sys <EOL> import textwrap <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> class WrappingLogFormatter ( logging . Formatter ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , format = None , date_format = None , max_width = <NUM_LIT> ) : <EOL> """<STR_LIT>""" <EOL> self . wrapper = textwrap . TextWrapper ( width = max_width , <EOL> subsequent_indent = '<STR_LIT:U+0020>' ) <EOL> logging . Formatter . __init__ ( self , format , date_format ) <EOL> def format ( self , record ) : <EOL> s = logging . Formatter . format ( self , record ) <EOL> result = [ ] <EOL> for line in s . split ( '<STR_LIT:\n>' ) : <EOL> result += [ self . wrapper . fill ( line ) ] <EOL> return '<STR_LIT:\n>' . join ( result ) <EOL> def init_simple_stream_logging ( level = logging . INFO , <EOL> streams = None , <EOL> format = None , <EOL> date_format = None ) : <EOL> """<STR_LIT>""" <EOL> if not streams : <EOL> streams = [ sys . stdout ] <EOL> if not format : <EOL> format = '<STR_LIT>' <EOL> if not date_format : <EOL> date_format = '<STR_LIT>' <EOL> logging . basicConfig ( level = level ) <EOL> handlers = [ ] <EOL> formatter = WrappingLogFormatter ( format = format , date_format = date_format ) <EOL> for stream in streams : <EOL> log_handler = logging . StreamHandler ( stream ) <EOL> log_handler . setLevel ( level ) <EOL> log_handler . setFormatter ( formatter ) <EOL> handlers += [ log_handler ] <EOL> logging . getLogger ( '<STR_LIT>' ) . handlers = handlers </s>
