<commit_before># -*- coding: utf-8 -*-

import eventlet
from eventlet.green import thread, threading

import logging
# from OpenStack Swift
logging.thread = eventlet.green.thread
logging.threading = eventlet.green.threading
logging._lock = logging.threading.RLock()


def create_generic_logger(name, handler, format, level):
    logger = logging.getLogger(name)
    logger.setLevel(level)
    handler.setLevel(level)
    formatter = logging.Formatter(format)
    handler.setFormatter(formatter)
    logger.addHandler(handler)

    log = logger.info
    log_exc = logger.exception

    return (log, log_exc, logger)


def create_logger(name, format='%(message)s', level=logging.DEBUG):
    '''
    Create eventlet compatible logger with given *name*, *format* and
    *level*.
    If format is not given, logger will print only message.
    Default log level -- DEBUG.
    Returns (log, log_exc, logger), where:
      log is wrapper around *logger.info*
      log_exc is wrapper around *logger.excption*
      logger -- is logger itself
    '''
    return create_generic_logger(name, logging.StreamHandler(),
                                 format, level)


__KEEP_FILEHANDLERS = False

def switch_keeping_filehandlers(boolval):
    global __KEEP_FILEHANDLERS
    __KEEP_FILEHANDLERS = bool(boolval)

__filehandlers = {}

def create_file_logger(name, filename,
                       format='%(message)s', level=logging.DEBUG):
    handler = logging.FileHandler(filename)
    if __KEEP_FILEHANDLERS:
        __filehandlers[(name, filename)] = handler
    return create_generic_logger(name, handler,
                                 format, level)

def stop_file_logger(name, filename):
    if (name, filename) in __filehandlers:
        logger = logging.getLogger(name)
        handler = __filehandlers[(name, filename)]
        logger.removeHandler(handler)
    else:
        raise Exception('No such handler registered: %s , %s' \
                         % (name, filename))<commit_msg>Update simple.py<commit_after># -*- coding: utf-8 -*-

import eventlet
from eventlet.green import thread, threading

import logging
# from OpenStack Swift
logging.thread = eventlet.green.thread
logging.threading = eventlet.green.threading
logging._lock = logging.threading.RLock()


def create_generic_logger(name, handler, format, level):
    logger = logging.getLogger(name)
    logger.setLevel(level)
    handler.setLevel(level)
    formatter = logging.Formatter(format)
    handler.setFormatter(formatter)
    logger.addHandler(handler)

    log = logger.info
    log_exc = logger.exception

    return (log, log_exc, logger)


def create_logger(name, format='%(message)s', level=logging.DEBUG):
    '''
    Create eventlet compatible logger with given *name*, *format* and
    *level*.
    If format is not given, logger will print only message.
    Default log level -- DEBUG.
    Returns (log, log_exc, logger), where:
      log is wrapper around *logger.info*
      log_exc is wrapper around *logger.excption*
      logger -- is logger itself
    '''
    return create_generic_logger(name, logging.StreamHandler(),
                                 format, level)


__KEEP_FILEHANDLERS = False

def switch_keeping_filehandlers(boolval):
    global __KEEP_FILEHANDLERS
    __KEEP_FILEHANDLERS = bool(boolval)

__filehandlers = {}

def create_file_logger(name, filename,
                       format='%(message)s', level=logging.DEBUG):
    handler = logging.FileHandler(filename)
    if __KEEP_FILEHANDLERS:
        __filehandlers[(name, filename)] = handler
    return create_generic_logger(name, handler,
                                 format, level)

def stop_file_logger(name, filename):
    if (name, filename) in __filehandlers:
        logger = logging.getLogger(name)
        handler = __filehandlers[(name, filename)]
        logger.removeHandler(handler)
        del __filehandlers[(name, filename)]
    else:
        raise Exception('No such handler registered: %s , %s' \
                         % (name, filename))
{'fraction_non_alphanumeric': 0.09687034277198212, 'fraction_numerical': 0.0004967709885742673, 'mean_word_length': 3.059475806451613, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5249132', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1125, 'n_words': 291}