<s> """<STR_LIT>""" <EOL> import logging <EOL> import sys <EOL> class LevelHandler ( logging . StreamHandler ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , stream_greater_or_equal = sys . stderr , <EOL> stream_lower = sys . stdout , <EOL> level = logging . ERROR ) : <EOL> """<STR_LIT>""" <EOL> logging . StreamHandler . __init__ ( self ) <EOL> self . _level = level <EOL> self . stream = None <EOL> self . _stream_lower = stream_lower <EOL> self . _stream_greater_or_equal = stream_greater_or_equal <EOL> def emit ( self , record ) : <EOL> """<STR_LIT>""" <EOL> if record . levelno >= self . _level : <EOL> return self . _emit ( record , self . _stream_greater_or_equal ) <EOL> else : <EOL> return self . _emit ( record , self . _stream_lower ) <EOL> def _emit ( self , record , stream ) : <EOL> self . stream = stream <EOL> try : <EOL> return logging . StreamHandler . emit ( self , record ) <EOL> except : <EOL> raise <EOL> else : <EOL> self . stream = None <EOL> def flush ( self ) : <EOL> if self . stream and hasattr ( self . stream , '<STR_LIT>' ) and not self . stream . closed : <EOL> logging . StreamHandler . flush ( self ) </s>
