<s> import sys <EOL> import os <EOL> import Console <EOL> quiet = False <EOL> logFile = None <EOL> labels = { <EOL> "<STR_LIT>" : ( ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , "<STR_LIT>" ) , <EOL> "<STR_LIT>" : ( ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , "<STR_LIT>" ) , <EOL> "<STR_LIT>" : ( ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , "<STR_LIT>" ) , <EOL> "<STR_LIT:error>" : ( ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , "<STR_LIT>" ) , <EOL> } <EOL> def _log ( label , msg , file = sys . stdout ) : <EOL> color , ident = labels [ label ] <EOL> if not quiet : <EOL> if file . isatty ( ) : <EOL> file . write ( "<STR_LIT:\r>" + "<STR_LIT:U+0020>" * <NUM_LIT> + "<STR_LIT:\r>" ) <EOL> Console . colorizer . setColor ( * color ) <EOL> file . write ( ident ) <EOL> if file . isatty ( ) : <EOL> Console . colorizer . resetColor ( ) <EOL> file . write ( "<STR_LIT:U+0020>" + str ( msg ) + "<STR_LIT:\n>" ) <EOL> if logFile : <EOL> print >> logFile , labels [ "<STR_LIT>" ] + "<STR_LIT:U+0020>" + str ( msg ) <EOL> warn = lambda msg : _log ( "<STR_LIT>" , msg ) <EOL> debug = lambda msg : _log ( "<STR_LIT>" , msg ) <EOL> notice = lambda msg : _log ( "<STR_LIT>" , msg ) <EOL> error = lambda msg : _log ( "<STR_LIT:error>" , msg ) </s>
