<commit_before># 记录日志
import logging
import os


class Logger:

    def __init__(self, log_path=None):
        self.format_str = '%(name)s %(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s'
        self.formatter = logging.Formatter(self.format_str)
        self.log_path = str(log_path)

        self.logger = logging.getLogger('app_logger')
        self.logger.setLevel(logging.NOTSET)

        logging.basicConfig(
                level=logging.DEBUG,
                format=self.format_str,
                filemode='a'
        )

    def do_log(self, data, context=None, path='',):
        file_handler = logging.FileHandler(path)
        file_handler.setFormatter(self.formatter)

        self.logger.addHandler(file_handler)
        # TODO level
        self.logger.debug(data + ' ' + str(context))
        self.logger.removeHandler(file_handler)
        return True

    def do_log_simple(self, data, context=None):
        self.logger.warning(data + ' ' + str(context))
        return True

    def gen_path(self, path):
        path = self.log_path + path + '/' + self.get_log_file_name()
        if not os.path.exists(path):
            dirname = os.path.dirname(path)<commit_msg>fix my hand shaking<commit_after># 记录日志
import logging
import os


class Logger:

    def __init__(self, log_path=None):
        self.format_str = '%(name)s %(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s'
        self.formatter = logging.Formatter(self.format_str)
        self.log_path = str(log_path)

        self.logger = logging.getLogger('app_logger')
        self.logger.setLevel(logging.NOTSET)

        logging.basicConfig(
                level=logging.DEBUG,
                format=self.format_str,
                filemode='a'
        )

    def do_log(self, data, context=None, path=''):
        file_handler = logging.FileHandler(path)
        file_handler.setFormatter(self.formatter)

        self.logger.addHandler(file_handler)
        # TODO level
        self.logger.debug(data + ' ' + str(context))
        self.logger.removeHandler(file_handler)
        return True

    def do_log_simple(self, data, context=None):
        self.logger.warning(data + ' ' + str(context))
        return True

    def gen_path(self, path):
        path = self.log_path + path + '/' + self.get_log_file_name()
        if not os.path.exists(path):
            dirname = os.path.dirname(path)
{'fraction_non_alphanumeric': 0.12174989682212134, 'fraction_numerical': 0.0, 'mean_word_length': 2.5028901734104045, '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': '6134707', 'n_tokens_mistral': 779, 'n_tokens_neox': 755, 'n_words': 130}