<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import , division , print_function , with_statement , unicode_literals <EOL> import logging <EOL> import time <EOL> from colorama import Fore , Style <EOL> LEVEL_COLORS = { <EOL> '<STR_LIT>' : Fore . BLUE , <EOL> '<STR_LIT>' : Fore . GREEN , <EOL> '<STR_LIT>' : Fore . YELLOW , <EOL> '<STR_LIT>' : Fore . RED , <EOL> '<STR_LIT>' : Fore . RED <EOL> } <EOL> def default_log_template ( self , record ) : <EOL> """<STR_LIT>""" <EOL> reset = Style . RESET_ALL <EOL> levelname = ( <EOL> LEVEL_COLORS . get ( record . levelname ) + Style . BRIGHT + <EOL> '<STR_LIT>' <EOL> + Style . RESET_ALL + '<STR_LIT:U+0020>' <EOL> ) <EOL> asctime = ( <EOL> '<STR_LIT:[>' + Fore . BLACK + Style . DIM + Style . BRIGHT + <EOL> '<STR_LIT>' <EOL> + Fore . RESET + Style . RESET_ALL + '<STR_LIT:]>' <EOL> ) <EOL> name = ( <EOL> '<STR_LIT:U+0020>' + Fore . WHITE + Style . DIM + Style . BRIGHT + <EOL> '<STR_LIT>' <EOL> + Fore . RESET + Style . RESET_ALL + '<STR_LIT:U+0020>' <EOL> ) <EOL> tpl = reset + levelname + asctime + name + reset <EOL> return tpl <EOL> class LogFormatter ( logging . Formatter ) : <EOL> template = default_log_template <EOL> def __init__ ( self , color = True , * args , ** kwargs ) : <EOL> logging . Formatter . __init__ ( self , * args , ** kwargs ) <EOL> def format ( self , record ) : <EOL> try : <EOL> record . message = record . getMessage ( ) <EOL> except Exception as e : <EOL> record . message = "<STR_LIT>" % ( e , record . __dict__ ) <EOL> date_format = '<STR_LIT>' <EOL> record . asctime = time . strftime ( <EOL> date_format , self . converter ( record . created ) <EOL> ) <EOL> prefix = self . template ( record ) % record . __dict__ <EOL> formatted = prefix + "<STR_LIT:U+0020>" + record . message <EOL> return formatted . replace ( "<STR_LIT:\n>" , "<STR_LIT>" ) <EOL> def debug_log_template ( self , record ) : <EOL> """<STR_LIT>""" <EOL> reset = Style . RESET_ALL <EOL> levelname = ( <EOL> LEVEL_COLORS . get ( record . levelname ) + Style . BRIGHT + <EOL> '<STR_LIT>' <EOL> + Style . RESET_ALL + '<STR_LIT:U+0020>' <EOL> ) <EOL> asctime = ( <EOL> '<STR_LIT:[>' + Fore . BLACK + Style . DIM + Style . BRIGHT + <EOL> '<STR_LIT>' <EOL> + Fore . RESET + Style . RESET_ALL + '<STR_LIT:]>' <EOL> ) <EOL> name = ( <EOL> '<STR_LIT:U+0020>' + Fore . WHITE + Style . DIM + Style . BRIGHT + <EOL> '<STR_LIT>' <EOL> + Fore . RESET + Style . RESET_ALL + '<STR_LIT:U+0020>' <EOL> ) <EOL> module_funcName = ( <EOL> Fore . GREEN + Style . BRIGHT + <EOL> '<STR_LIT>' <EOL> ) <EOL> lineno = ( <EOL> Fore . BLACK + Style . DIM + Style . BRIGHT + '<STR_LIT::>' + Style . RESET_ALL + <EOL> Fore . CYAN + '<STR_LIT>' <EOL> ) <EOL> tpl = reset + levelname + asctime + name + module_funcName + lineno + reset <EOL> return tpl <EOL> class DebugLogFormatter ( LogFormatter ) : <EOL> """<STR_LIT>""" <EOL> template = debug_log_template </s>
