<commit_before>import constants


def wrap(message, max_length):
    if not message:
        return message

    if len(message) > max_length:
        return message[:max_length]

    return message


def reason(message):
    return wrap(message, constants.MAX_REASON_LENGTH)


def details(message):
    return wrap(message, constants.MAX_DETAILS_LENGTH)


def input(message):
    return wrap(message, constants.MAX_INPUT_LENGTH)


def result(message):
    return wrap(message, constants.MAX_RESULT_LENGTH)<commit_msg>Update format: log warning message when truncating an error<commit_after>import constants
import logging


logger = logging.getLogger(__name__)


def wrap(message, max_length):
    if not message:
        return message

    if len(message) > max_length:
        logger.warning(
            'message "{}" too long ({} chars), wrapped to {}'.format(
                message,
                len(message),
                max_length,
            ))
        return message[:max_length]

    return message


def reason(message):
    return wrap(message, constants.MAX_REASON_LENGTH)


def details(message):
    return wrap(message, constants.MAX_DETAILS_LENGTH)


def input(message):
    return wrap(message, constants.MAX_INPUT_LENGTH)


def result(message):
    return wrap(message, constants.MAX_RESULT_LENGTH)
{'fraction_non_alphanumeric': 0.08659638554216867, 'fraction_numerical': 0.0, 'mean_word_length': 3.3289902280130295, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3570415', 'n_tokens_mistral': 386, 'n_tokens_neox': 362, 'n_words': 96}