Ejemplo n.º 1
0
def configure_logging():
    """Configure root logger"""
    logger = logging.getLogger()

    logger.setLevel(logging.DEBUG)

    # Level name colored differently (both console and file)
    logging.addLevelName(logging.WARNING, "\x1b[0;33m%s\x1b[0m" % logging.getLevelName(logging.WARNING))
    logging.addLevelName(logging.ERROR, "\x1b[0;31m%s\x1b[0m" % logging.getLevelName(logging.ERROR))

    # Configure console logging
    console_log_handler = logging.StreamHandler()
    console_log_handler.setLevel(logging.INFO)
    # All console messages are the same color (except with colored level names)
    console_formatter = logging.Formatter("\x1b[0;32m%(levelname)s" "\t%(message)s\x1b[0m")
    console_log_handler.setFormatter(console_formatter)
    logger.addHandler(console_log_handler)

    # Configure log file
    hf.clean_dir(conf.log_dir)
    log_file = os.path.join(conf.log_dir, "stacktrain.log")
    file_log_handler = logging.FileHandler(log_file)
    file_log_handler.setLevel(logging.DEBUG)
    file_formatter = logging.Formatter(
        "%(process)s %(asctime)s.%(msecs)03d" " %(name)s %(levelname)s %(message)s", datefmt="%H:%M:%S"
    )
    file_log_handler.setFormatter(file_formatter)
    logger.addHandler(file_log_handler)

    logger.debug("Root logger configured.")
Ejemplo n.º 2
0
def configure_logging():
    """Configure root logger"""
    logger = logging.getLogger()

    logger.setLevel(logging.DEBUG)

    # Level name colored differently (both console and file)
    logging.addLevelName(logging.WARNING, '\x1b[0;33m%s\x1b[0m' %
                         logging.getLevelName(logging.WARNING))
    logging.addLevelName(logging.ERROR, '\x1b[0;31m%s\x1b[0m' %
                         logging.getLevelName(logging.ERROR))

    # Configure console logging
    console_log_handler = logging.StreamHandler()
    console_log_handler.setLevel(logging.INFO)
    # All console messages are the same color (except with colored level names)
    console_formatter = logging.Formatter('\x1b[0;32m%(levelname)s'
                                          '\t%(message)s\x1b[0m')
    console_log_handler.setFormatter(console_formatter)
    logger.addHandler(console_log_handler)

    # Configure log file
    hf.clean_dir(conf.log_dir)
    log_file = os.path.join(conf.log_dir, 'stacktrain.log')
    file_log_handler = logging.FileHandler(log_file)
    file_log_handler.setLevel(logging.DEBUG)
    file_formatter = logging.Formatter('%(process)s %(asctime)s.%(msecs)03d'
                                       ' %(name)s %(levelname)s %(message)s',
                                       datefmt="%H:%M:%S")
    file_log_handler.setFormatter(file_formatter)
    logger.addHandler(file_log_handler)

    logger.debug("Root logger configured.")
Ejemplo n.º 3
0
def wbatch_reset():
    """Clean Windows batch directory"""
    hf.clean_dir(WBATCH_OUT_DIR)
Ejemplo n.º 4
0
def autostart_reset():
    logger.info('%s(): caller: %s()', log_utils.get_fname(1),
                log_utils.get_fname(2))
    logger.debug("Resetting autostart directories.")
    hf.clean_dir(conf.autostart_dir)
    hf.clean_dir(conf.status_dir)
def wbatch_reset():
    """Clean Windows batch directory"""
    hf.clean_dir(WBATCH_OUT_DIR)
    copyfile(os.path.join(TPLT_DIR, "config_bat"),
             os.path.join(WBATCH_OUT_DIR, "config.bat"))
Ejemplo n.º 6
0
def autostart_reset():
    logger.debug("Resetting autostart directories.")
    hf.clean_dir(conf.autostart_dir)
    hf.clean_dir(conf.status_dir)
Ejemplo n.º 7
0
def autostart_reset():
    logger.debug("Resetting autostart directories.")
    hf.clean_dir(conf.autostart_dir)
    hf.clean_dir(conf.status_dir)