
import logging
import logging.config
import six
from six import moves


logging.AUDIT = logging.CRITICAL + 10
logging.addLevelName(logging.AUDIT, 'AUDIT')


_loggers = {}


def setup(config_file):
    """Configure logging from file.
    """
    try:
        logging.config.fileConfig(config_file,
                                  defaults=None,
                                  disable_existing_loggers=False)
    except moves.configparser.Error as exc:
        raise Exception(six.text_type(exc))


def getLogger(name, extra=None):
    if name not in _loggers:
        _loggers[name] = AuditLoggerAdapter(logging.getLogger(name), extra)
    return _loggers[name]


class AuditLoggerAdapter(logging.LoggerAdapter):
    """Logger adapter to write message with the audit log level.
    """

    def audit(self, msg, *args, **kwargs):
        self.log(logging.AUDIT, msg, *args, **kwargs)

    def setLevel(self, lvl):
        self.logger.setLevel(lvl)

    def getEffectiveLevel(self):
        return self.logger.getEffectiveLevel()

@@ -155,21 +155,178 @@
 )%0A%0A%0A
-_loggers = %7B%7D
+def _audit(logger, msg, *args, **kwargs):%0A    if logger.isEnabledFor(logging.AUDIT):%0A        logger._log(logging.AUDIT, msg, args, **kwargs)%0Alogging.Logger.audit = _audit
 %0A%0A%0Ad
@@ -675,517 +675,42 @@
 name
-, extra=None):%0A    if name not in _loggers:%0A        _loggers%5Bname%5D = AuditLoggerAdapter(logging.getLogger(name), extra)%0A    return _loggers%5Bname%5D%0A%0A%0Aclass AuditLoggerAdapter(logging.LoggerAdapter):%0A    %22%22%22Logger adapter to write message with the audit log level.%0A    %22%22%22%0A%0A    def audit(self, msg, *args, **kwargs):%0A        self.log(logging.AUDIT, msg, *args, **kwargs)%0A%0A    def setLevel(self, lvl):%0A        self.logger.setLevel(lvl)%0A%0A    def getEffectiveLevel(self):%0A        return self.logger.getEffectiveLevel(
+):%0A    return logging.getLogger(name
 )%0A

Simplify audit level in logger