

def setup_logging(config=None):
    "Turn down dependent library log levels so they aren't noise."
    global CONFIGURED
    FORMAT = '%(asctime)s  %(levelname)-8s [%(name)-15s] %(message)s'
    DATEFMT = '%Y-%m-%d %H:%M:%S'
    loglevels = {
        'irc.client': logging.INFO,
        'gerrit.GerritWatcher': logging.INFO,
        'paramiko.transport': logging.INFO,
        'pyelasticsearch': logging.INFO,
        'requests.packages.urllib3.connectionpool': logging.WARN,
        'urllib3.connectionpool': logging.WARN,
    }
    if ((config is not None) and config.has_option('ircbot', 'log_config')):
        log_config = config.get('ircbot', 'log_config')
        fp = os.path.expanduser(log_config)
        if (not os.path.exists(fp)):
            raise Exception(('Unable to read logging config file at %s' % fp))
        logging.config.fileConfig(fp)
    else:
        logging.basicConfig(level=logging.DEBUG, format=FORMAT, datefmt=DATEFMT)
        for module in loglevels:
            log = logging.getLogger(module)
            log.setLevel(loglevels[module])
    CONFIGURED = True

dataset/ETHPy150Open openstack-infra/elastic-recheck/elastic_recheck/log.py setup_logging/original