<commit_before>import logging
import json
import zlib
import os
import struct
import traceback


_levels = {
    logging.DEBUG: 7,
    logging.INFO: 6,
    logging.WARNING: 4,
    logging.ERROR: 3,
    logging.CRITICAL: 2
}


# skip_list is used to filter additional fields in a log message.
# It contains all attributes listed in
# http://docs.python.org/library/logging.html#logrecord-attributes
# plus exc_text, which is only found in the logging module source,
# and id, which is prohibited by the GELF format.
_skip_list = (
    'args', 'asctime', 'created', 'exc_info', 'exc_text', 'filename',
    'funcName', 'id', 'levelname', 'levelno', 'lineno', 'module',
    'msecs', 'message', 'msg', 'name', 'pathname', 'process',
    'processName', 'relativeCreated', 'thread', 'threadName'
)


def make(record, domain, debug, version, additional_fields, include_extra_fields=False):
    gelf = {
        'version': version,
        'short_message': record.getMessage(),
        'timestamp': record.created,
        'level': _levels[record.levelno],
        'source': domain
    }

    if record.exc_info is not None:
        gelf['full_message'] = '\n'.join(traceback.format_exception(*record.exc_info))<commit_msg>Rename source to host to match GELF expected field.<commit_after>import logging
import json
import zlib
import os
import struct
import traceback


_levels = {
    logging.DEBUG: 7,
    logging.INFO: 6,
    logging.WARNING: 4,
    logging.ERROR: 3,
    logging.CRITICAL: 2
}


# skip_list is used to filter additional fields in a log message.
# It contains all attributes listed in
# http://docs.python.org/library/logging.html#logrecord-attributes
# plus exc_text, which is only found in the logging module source,
# and id, which is prohibited by the GELF format.
_skip_list = (
    'args', 'asctime', 'created', 'exc_info', 'exc_text', 'filename',
    'funcName', 'id', 'levelname', 'levelno', 'lineno', 'module',
    'msecs', 'message', 'msg', 'name', 'pathname', 'process',
    'processName', 'relativeCreated', 'thread', 'threadName'
)


def make(record, domain, debug, version, additional_fields, include_extra_fields=False):
    gelf = {
        'version': version,
        'short_message': record.getMessage(),
        'timestamp': record.created,
        'level': _levels[record.levelno],
        'host': domain
    }

    if record.exc_info is not None:
        gelf['full_message'] = '\n'.join(traceback.format_exception(*record.exc_info))
{'fraction_non_alphanumeric': 0.13352272727272727, 'fraction_numerical': 0.004058441558441558, 'mean_word_length': 3.8523622047244093, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6836367', 'n_tokens_mistral': 780, 'n_tokens_neox': 761, 'n_words': 225}