예제 #1
0
def setup_logging(opts):
    """
    Setup log file
    """
    clear_root_handlers()
    if hasattr(opts, "log_level"):
        log_level = opts.log_level or HOLLANDCFG.lookup("logging.level")
    else:
        log_level = HOLLANDCFG.lookup("logging.level")

    if not opts.quiet:
        setup_console_logging(level=log_level)

    if HOLLANDCFG.lookup("logging.filename"):
        try:
            if HOLLANDCFG.lookup("logging.format"):
                setup_file_logging(
                    filename=str(HOLLANDCFG.lookup("logging.filename")),
                    level=log_level,
                    msg_format=HOLLANDCFG.lookup(str("logging.format")),
                )
            else:
                setup_file_logging(
                    filename=str(HOLLANDCFG.lookup("logging.filename")), level=log_level
                )
        except IOError as exc:
            LOG.warning("Skipping file logging: %s", exc)
예제 #2
0
def setup_logging(opts):
    """
    Setup log file
    """
    clear_root_handlers()
    if hasattr(opts, "log_level"):
        log_level = opts.log_level or HOLLANDCFG.lookup("logging.level")
    else:
        log_level = HOLLANDCFG.lookup("logging.level")

    if not opts.quiet:
        setup_console_logging(level=log_level)

    if HOLLANDCFG.lookup("logging.filename"):
        try:
            if HOLLANDCFG.lookup("logging.format"):
                setup_file_logging(
                    filename=str(HOLLANDCFG.lookup("logging.filename")),
                    level=log_level,
                    msg_format=HOLLANDCFG.lookup(str("logging.format")),
                )
            else:
                setup_file_logging(filename=str(
                    HOLLANDCFG.lookup("logging.filename")),
                                   level=log_level)
        except IOError as exc:
            LOG.warning("Skipping file logging: %s", exc)
예제 #3
0
def setup_logging(opts):
    clear_root_handlers()
    if hasattr(opts, 'log_level'):
        log_level = opts.log_level or hollandcfg.lookup('logging.level')
    else:
        log_level = hollandcfg.lookup('logging.level')

    if (not opts.quiet):
        setup_console_logging(level=log_level)

    if hollandcfg.lookup('logging.filename'):
        try:
            if hollandcfg.lookup('logging.format'):
                setup_file_logging(
                    filename=str(hollandcfg.lookup('logging.filename')),
                    level=log_level,
                    format=hollandcfg.lookup(str('logging.format')))
            else:
                setup_file_logging(filename=str(
                    hollandcfg.lookup('logging.filename')),
                                   level=log_level)
        except IOError as exc:
            LOGGER.warn("Skipping file logging: %s", exc)

    # Monkey patch in routing warnings through logging
    old_showwarning = warnings.showwarning
    warnings.showwarning = log_warnings
예제 #4
0
def setup_logging(opts):
    clear_root_handlers()
    if hasattr(opts, "log_level"):
        log_level = opts.log_level or hollandcfg.lookup("logging.level")
    else:
        log_level = hollandcfg.lookup("logging.level")

    if os.isatty(sys.stdin.fileno()) and not opts.quiet:
        setup_console_logging(level=log_level)

    if hollandcfg.lookup("logging.filename"):
        try:
            setup_file_logging(filename=str(hollandcfg.lookup("logging.filename")), level=log_level)
        except IOError, exc:
            LOGGER.warn("Skipping file logging: %s", exc)
예제 #5
0
def setup_logging(opts):
    clear_root_handlers()
    if hasattr(opts, 'log_level'):
        log_level = opts.log_level or hollandcfg.lookup('logging.level')
    else:
        log_level = hollandcfg.lookup('logging.level')

    if (not opts.quiet):
        setup_console_logging(level=log_level)

    if hollandcfg.lookup('logging.filename'):
        try:
            setup_file_logging(filename=str(hollandcfg.lookup('logging.filename')),
                               level=log_level)
        except IOError, exc:
            LOGGER.warn("Skipping file logging: %s", exc)
예제 #6
0
def setup_logging(opts):
    clear_root_handlers()
    if hasattr(opts, 'log_level'):
        log_level = opts.log_level or hollandcfg.lookup('logging.level')
    else:
        log_level = hollandcfg.lookup('logging.level')

    if (not opts.quiet):
        setup_console_logging(level=log_level)

    if hollandcfg.lookup('logging.filename'):
        try:
            setup_file_logging(filename=str(
                hollandcfg.lookup('logging.filename')),
                               level=log_level)
        except IOError, exc:
            LOGGER.warn("Skipping file logging: %s", exc)
예제 #7
0
def setup_logging(opts):
    clear_root_handlers()
    if hasattr(opts, 'log_level'):
        log_level = opts.log_level or hollandcfg.lookup('logging.level')
    else:
        log_level = hollandcfg.lookup('logging.level')

    if (os.isatty(sys.stdin.fileno()) and not opts.quiet):
        setup_console_logging(level=log_level)

    if hollandcfg.lookup('logging.filename'):
        setup_file_logging(filename=hollandcfg.lookup('logging.filename'),
                           level=log_level)

    # Monkey patch in routing warnings through logging
    old_showwarning = warnings.showwarning
    warnings.showwarning = log_warnings
예제 #8
0
    def setUp(self):
        clear_root_handlers()
        # This is tested in test_config.py
        self.tmpdir = tempfile.mkdtemp()
        log_file = os.path.join(self.tmpdir, 'holland.log')
        test_cfg = """
        [holland]
        plugin_dirs = /usr/share/holland/plugins
        backupsets = default
        umask = 0007
        path = /bin:/usr/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin

        [logging]
        level = critical
        filename = %s
        """ % (log_file)
        path = os.path.join(self.tmpdir, 'holland.conf')
        open(path, 'w').write(test_cfg)
        setup_config(path)
예제 #9
0
    def setUp(self):
        clear_root_handlers()
        # This is tested in test_config.py
        self.tmpdir = tempfile.mkdtemp()
        log_file = os.path.join(self.tmpdir, 'holland.log')
        test_cfg = """
        [holland]
        plugin_dirs = /usr/share/holland/plugins
        backupsets = default
        umask = 0007
        path = /bin:/usr/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin

        [logging]
        level = critical
        filename = %s
        """ % (log_file)
        path = os.path.join(self.tmpdir, 'holland.conf')
        open(path, 'w').write(test_cfg)
        setup_config(path)