Example #1
0
def fileConfig(fname, defaults=None, disable_existing_loggers=True):

    import ConfigParser

    cp = ConfigParser.ConfigParser(defaults)
    if hasattr(fname, 'readline'):
        cp.readfp(fname)
    else:
        cp.read(fname)

    formatters = _create_formatters(cp)

    logging._acquireLock()
    try:
        logging._handlers.clear()
        del logging._handlerList[:]
        handlers = _install_handlers(cp, formatters)
        _install_loggers(cp, handlers, disable_existing_loggers)
    finally:
        logging._releaseLock()
Example #2
0
def fileConfig(fname, defaults=None, disable_existing_loggers=True):

    import ConfigParser

    cp = ConfigParser.ConfigParser(defaults)
    if hasattr(fname, 'readline'):
        cp.readfp(fname)
    else:
        cp.read(fname)

    formatters = _create_formatters(cp)

    logging._acquireLock()
    try:
        logging._handlers.clear()
        del logging._handlerList[:]
        handlers = _install_handlers(cp, formatters)
        _install_loggers(cp, handlers, disable_existing_loggers)
    finally:
        logging._releaseLock()
Example #3
0
    def __fileConfig(config, disable_existing_loggers=True):
        """
        Read the logging configuration from a ConfigParser-format file.
        This can be called several times from an application, allowing an end user
        the ability to select from various pre-canned configurations (if the
        developer provides a mechanism to present the choices and load the chosen
        configuration).
        """

        formatters = logging_config._create_formatters(config)

        # critical section
        logging._acquireLock()
        try:
            logging._handlers.clear()
            del logging._handlerList[:]
            # Handlers add themselves to logging._handlers
            handlers = logging_config._install_handlers(config, formatters)
            logging_config._install_loggers(config, handlers, disable_existing_loggers)
        finally:
            logging._releaseLock()
    def __fileConfig(config, disable_existing_loggers=True):
        """
        Read the logging configuration from a ConfigParser-format file.

        This can be called several times from an application, allowing an end user
        the ability to select from various pre-canned configurations (if the
        developer provides a mechanism to present the choices and load the chosen
        configuration).
        """

        formatters = logging_config._create_formatters(config)

        # critical section
        logging._acquireLock()
        try:
            logging._handlers.clear()
            del logging._handlerList[:]
            # Handlers add themselves to logging._handlers
            handlers = logging_config._install_handlers(config, formatters)
            logging_config._install_loggers(config, handlers, disable_existing_loggers)
        finally:
            logging._releaseLock()
Example #5
0
def configLogging(fname, logPath):

    cp = ConfigParser.ConfigParser()
    if hasattr(cp, 'readfp') and hasattr(fname, 'readline'):
        cp.readfp(fname)
    else:
        cp.read(fname)

    logfile = os.path.join(logPath, 'CouchPotato.log')
    if os.name == 'nt':
        logfile = logfile.replace('\\', '\\\\')
    cp.set('handler_accesslog', 'args', cp.get('handler_accesslog', 'args').replace('{logPath}', logfile))

    formatters = _create_formatters(cp)

    # critical section
    logging._acquireLock()
    try:
        logging._handlers.clear()
        del logging._handlerList[:]
        handlers = _install_handlers(cp, formatters)
        _install_loggers(cp, handlers, 1)
    finally:
        logging._releaseLock()