<commit_before>from __future__ import absolute_import
import sys
import logging

LOG_LEVELS = {
    "CRITICAL": logging.CRITICAL,
    "ERROR": logging.ERROR,
    "WARNING": logging.WARNING,
    "INFO": logging.INFO,
    "DEBUG": logging.DEBUG
}


def get_log_level(level):
    return LOG_LEVELS.get(level, logging.INFO)
    

def set_log_level(level):
    loglevel = LOG_LEVELS.get(level, logging.INFO)
    logging.basicConfig(level=loglevel)
    

notify_logger = logging.getLogger('notify')


def notify_error(message):
    notify_logger.error(message)


def notify_exception(request, message=None, details=None, exec_info=None):
    """
    :param request: a Django request object
    :param message: message string
    :param details: dict with additional details to be included in the output
    """
    if request is not None:
        message = message or request.path
    notify_logger.error(
        'Notify Exception: %s' % (message
                                  or "No message provided, fix error handler"),
        exc_info=exec_info or sys.exc_info(),
        extra={
            'status_code': 500,
            'request': request,
            'details': details,
        }
    )


def notify_js_exception(request, message=None, details=None):
    notify_logger.error(
        'Notify JS Exception: {}'.format(message),
        extra={
            'request': request,
            'details': details,
        }
    )
<commit_msg>create function for logging signal errors<commit_after>from __future__ import absolute_import
import sys
import logging

LOG_LEVELS = {
    "CRITICAL": logging.CRITICAL,
    "ERROR": logging.ERROR,
    "WARNING": logging.WARNING,
    "INFO": logging.INFO,
    "DEBUG": logging.DEBUG
}


def get_log_level(level):
    return LOG_LEVELS.get(level, logging.INFO)
    

def set_log_level(level):
    loglevel = LOG_LEVELS.get(level, logging.INFO)
    logging.basicConfig(level=loglevel)
    

notify_logger = logging.getLogger('notify')


def notify_error(message):
    notify_logger.error(message)


def notify_exception(request, message=None, details=None, exec_info=None):
    """
    :param request: a Django request object
    :param message: message string
    :param details: dict with additional details to be included in the output
    """
    if request is not None:
        message = message or request.path
    notify_logger.error(
        'Notify Exception: %s' % (message
                                  or "No message provided, fix error handler"),
        exc_info=exec_info or sys.exc_info(),
        extra={
            'status_code': 500,
            'request': request,
            'details': details,
        }
    )


def log_signal_errors(signal_results, message, details):
    for result in signal_results:
        # Second argument is None if there was no error
        return_val = result[1]
        if return_val and isinstance(return_val, Exception):
            notify_exception(
                None,
                message=message % return_val.__class__.__name__,
                details=details,
                exec_info=(type(return_val), return_val, return_val.__traceback__)
            )


def notify_js_exception(request, message=None, details=None):
    notify_logger.error(
        'Notify JS Exception: {}'.format(message),
        extra={
            'request': request,
            'details': details,
        }
    )

{'fraction_non_alphanumeric': 0.09811985898942421, 'fraction_numerical': 0.002056404230317274, 'mean_word_length': 2.5955649419218587, 'pattern_counts': {'":': 10, '<': 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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1271198', 'n_tokens_mistral': 971, 'n_tokens_neox': 953, 'n_words': 251}