def enable_pretty_logging(options=None, logger=None):
 if (options is None):
  import tornado.options
  options = tornado.options.options
 if ((options.logging is None) or (options.logging.lower() == 'none')):
  return
 if (logger is None):
  logger = logging.getLogger()
 logger.setLevel(getattr(logging, options.logging.upper()))
 if options.log_file_prefix:
  rotate_mode = options.log_rotate_mode
  if (rotate_mode == 'size'):
   channel = logging.handlers.RotatingFileHandler(filename=options.log_file_prefix, maxBytes=options.log_file_max_size, backupCount=options.log_file_num_backups)
  elif (rotate_mode == 'time'):
   channel = logging.handlers.TimedRotatingFileHandler(filename=options.log_file_prefix, when=options.log_rotate_when, interval=options.log_rotate_interval, backupCount=options.log_file_num_backups)
  else:
   error_message = ('The value of log_rotate_mode option should be ' + ('"size" or "time", not "%s".' % rotate_mode))
   raise ValueError(error_message)
  channel.setFormatter(LogFormatter(color=False))
  logger.addHandler(channel)
 if (options.log_to_stderr or ((options.log_to_stderr is None) and (not logger.handlers))):
  channel = logging.StreamHandler()
  channel.setFormatter(LogFormatter())
  logger.addHandler(channel)

def enable_pretty_logging ( options = None , logger = None ) : if ( options is None ) : import tornado . options options = tornado . options . options if ( ( options . logging is None ) or ( options . logging . lower ( ) == 'none' ) ) : return if ( logger is None ) : logger = logging . getLogger ( ) logger . setLevel ( getattr ( logging , options . logging . upper ( ) ) ) if options . log_file_prefix : rotate_mode = options . log_rotate_mode if ( rotate_mode == 'size' ) : channel = logging . handlers . RotatingFileHandler ( filename = options . log_file_prefix , maxBytes = options . log_file_max_size , backupCount = options . log_file_num_backups ) elif ( rotate_mode == 'time' ) : channel = logging . handlers . TimedRotatingFileHandler ( filename = options . log_file_prefix , when = options . log_rotate_when , interval = options . log_rotate_interval , backupCount = options . log_file_num_backups ) else : error_message = ( 'The value of log_rotate_mode option should be ' + ( '"size" or "time", not "%s".' % rotate_mode ) ) raise ValueError ( error_message ) channel . setFormatter ( LogFormatter ( color = False ) ) logger . addHandler ( channel ) if ( options . log_to_stderr or ( ( options . log_to_stderr is None ) and ( not logger . handlers ) ) ) : channel = logging . StreamHandler ( ) channel . setFormatter ( LogFormatter ( ) ) logger . addHandler ( channel )
turns on formatted logging output as configured .