def configure_debug_log_handlers(logger):
 global printed_log_start_message
 logger.setLevel(logging.DEBUG)
 logging_to_file = True
 try:
  make_sure_path_exists(os.path.dirname(log_filepath), 448)
  debug_handler = logging.FileHandler(log_filepath)
 except (OSError, IOError):
  logging_to_file = False
  debug_handler = logging.StreamHandler()
 debug_handler.setLevel(logging.DEBUG)
 important_handler = logging.StreamHandler()
 important_handler.setLevel(logging.WARNING)
 logger.addHandler(debug_handler)
 logger.addHandler(important_handler)
 if (not printed_log_start_message):
  logger.info(u'!-- begin debug log --!')
  logger.info((u'version: ' + __version__))
  if logging_to_file:
   logger.info((u'logging to: ' + log_filepath))
  printed_log_start_message = True
 formatter = logging.Formatter(u'%(asctime)s - %(name)s (%(module)s:%(lineno)s) [%(levelname)s]: %(message)s')
 debug_handler.setFormatter(formatter)
 important_handler.setFormatter(formatter)

def configure_debug_log_handlers ( logger ) : global printed_log_start_message logger . setLevel ( logging . DEBUG ) logging_to_file = True try : make_sure_path_exists ( os . path . dirname ( log_filepath ) , 448 ) debug_handler = logging . FileHandler ( log_filepath ) except ( OSError , IOError ) : logging_to_file = False debug_handler = logging . StreamHandler ( ) debug_handler . setLevel ( logging . DEBUG ) important_handler = logging . StreamHandler ( ) important_handler . setLevel ( logging . WARNING ) logger . addHandler ( debug_handler ) logger . addHandler ( important_handler ) if ( not printed_log_start_message ) : logger . info ( u'!-- begin debug log --!' ) logger . info ( ( u'version: ' + __version__ ) ) if logging_to_file : logger . info ( ( u'logging to: ' + log_filepath ) ) printed_log_start_message = True formatter = logging . Formatter ( u'%(asctime)s - %(name)s (%(module)s:%(lineno)s) [%(levelname)s]: %(message)s' ) debug_handler . setFormatter ( formatter ) important_handler . setFormatter ( formatter )
warnings and above to stderr .