Exemplo n.º 1
0
def napalm_logs_engine():
    if '' in sys.path:
        sys.path.remove('')
    # Temporarily will forward the log entries to the screen
    # After reading the config and all good, will write into the right
    # log file.
    screen_logger = logging.StreamHandler(sys.stdout)
    screen_logger.setFormatter(logging.Formatter(defaults.LOG_FORMAT))
    log.addHandler(screen_logger)
    nlop = NLOptionParser()
    config = nlop.parse(screen_logger)
    nl = napalm_logs.NapalmLogs(**config)
    try:
        nl.start_engine()
    except KeyboardInterrupt:
        log.warning('Exiting on Ctrl-c')
        nl.stop_engine()
Exemplo n.º 2
0
def napalm_logs_engine():
    if '' in sys.path:
        sys.path.remove('')
    # Temporarily will forward the log entries to the screen
    # After reading the config and all good, will write into the right
    # log file.
    screen_logger = logging.StreamHandler(sys.stdout)
    screen_logger.setFormatter(logging.Formatter(defaults.LOG_FORMAT))
    log.addHandler(screen_logger)
    nlop = NLOptionParser()
    config = nlop.parse(log, screen_logger)
    # Ignore SIGINT whilst starting child processes so they inherit the ignore
    signal.signal(signal.SIGINT, signal.SIG_IGN)
    signal.signal(signal.SIGTERM, signal.SIG_IGN)
    nl = napalm_logs.NapalmLogs(**config)
    nl.start_engine()
    # Set SIGINT to _exit_gracefully so we can close everything down gracefully
    signal.signal(signal.SIGINT, _exit_gracefully)
    signal.signal(signal.SIGTERM, _exit_gracefully)
    # Keep this function running until we receive instruction to terminate
    while _up is True and nl.up is True:
        time.sleep(1)
    nl.stop_engine()