def set_werkzeug_log_color():
 from django.core.management.color import color_style
 from werkzeug.serving import WSGIRequestHandler
 from werkzeug._internal import _log
 _style = color_style()
 _orig_log = WSGIRequestHandler.log
 def werk_log(self, type, message, *args):
  try:
   msg = ('%s - - [%s] %s' % (self.address_string(), self.log_date_time_string(), (message % args)))
   http_code = str(args[1])
  except:
   return _orig_log(type, message, *args)
  if (http_code[0] == '2'):
   msg = _style.HTTP_SUCCESS(msg)
  elif (http_code[0] == '1'):
   msg = _style.HTTP_INFO(msg)
  elif (http_code == '304'):
   msg = _style.HTTP_NOT_MODIFIED(msg)
  elif (http_code[0] == '3'):
   msg = _style.HTTP_REDIRECT(msg)
  elif (http_code == '404'):
   msg = _style.HTTP_NOT_FOUND(msg)
  elif (http_code[0] == '4'):
   msg = _style.HTTP_BAD_REQUEST(msg)
  else:
   msg = _style.HTTP_SERVER_ERROR(msg)
  _log(type, msg)
 WSGIRequestHandler.log = werk_log

def set_werkzeug_log_color ( ) : from django . core . management . color import color_style from werkzeug . serving import WSGIRequestHandler from werkzeug . _internal import _log _style = color_style ( ) _orig_log = WSGIRequestHandler . log def werk_log ( self , type , message , * args ) : try : msg = ( '%s - - [%s] %s' % ( self . address_string ( ) , self . log_date_time_string ( ) , ( message % args ) ) ) http_code = str ( args [ 1 ] ) except : return _orig_log ( type , message , * args ) if ( http_code [ 0 ] == '2' ) : msg = _style . HTTP_SUCCESS ( msg ) elif ( http_code [ 0 ] == '1' ) : msg = _style . HTTP_INFO ( msg ) elif ( http_code == '304' ) : msg = _style . HTTP_NOT_MODIFIED ( msg ) elif ( http_code [ 0 ] == '3' ) : msg = _style . HTTP_REDIRECT ( msg ) elif ( http_code == '404' ) : msg = _style . HTTP_NOT_FOUND ( msg ) elif ( http_code [ 0 ] == '4' ) : msg = _style . HTTP_BAD_REQUEST ( msg ) else : msg = _style . HTTP_SERVER_ERROR ( msg ) _log ( type , msg ) WSGIRequestHandler . log = werk_log
try to set color to the werkzeug log .