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

import os
import getpass
import yaml
import sys


class Logger(object):
    def __init__(self, name, loglevel, logfile):
        # Create log directory if not exists.
        logdir = os.path.dirname(logfile)
        if not os.path.exists(logdir):
            try:
                os.makedirs(logdir)
            except OSError as oserr:
                print("Unable to create log directory: %s" % oserr)
                sys.exit(1)

        # Initialize logger
        import logging
        self.logger = logging.getLogger(name)
        self.logger.setLevel(loglevel.upper())

        # Add file handler.
        file_formatter = logging.Formatter(
            '%(asctime)s '+ getpass.getuser() +' %(levelname)s: %(message)s'
        )
        file_handler = logging.FileHandler(logfile)
        file_handler.setFormatter(file_formatter)
        self.logger.addHandler(file_handler)

        # Add console handler.
        cli_formatter = logging.Formatter(
            '%(asctime)s %(levelname)s: %(message)s'
        )
        cli_handler = logging.StreamHandler()
        cli_handler.setFormatter(cli_formatter)
        self.logger.addHandler(cli_handler)


    def debug(self, msg, quit=False):
        self.logger.debug(msg)
        if quit:
            sys.exit(0)


    def info(self, msg, quit=False):
        self.logger.info(msg)
        if quit:
            sys.exit(0)


    def warn(self, msg, quit=False):
        self.logger.warn(msg)
        if quit:
            sys.exit(1)


    def error(self, msg, quit=False):
        self.logger.error(msg)
        if quit:
            sys.exit(1)<commit_msg>Add a "prompt" to logging function of Logger class.<commit_after># -*- coding: utf-8 -*-

import os
import getpass
import yaml
import sys


class Logger(object):
    def __init__(self, name, loglevel, logfile):
        # Create log directory if not exists.
        logdir = os.path.dirname(logfile)
        if not os.path.exists(logdir):
            try:
                os.makedirs(logdir)
            except OSError as oserr:
                print("Unable to create log directory: %s" % oserr)
                sys.exit(1)

        # Initialize logger
        import logging
        self.logger = logging.getLogger(name)
        self.logger.setLevel(loglevel.upper())

        # Add file handler.
        file_formatter = logging.Formatter(
            '%(asctime)s '+ getpass.getuser() +' %(levelname)s: %(message)s'
        )
        file_handler = logging.FileHandler(logfile)
        file_handler.setFormatter(file_formatter)
        self.logger.addHandler(file_handler)

        # Add console handler.
        cli_formatter = logging.Formatter(
            '%(asctime)s %(levelname)s: %(message)s'
        )
        cli_handler = logging.StreamHandler()
        cli_handler.setFormatter(cli_formatter)
        self.logger.addHandler(cli_handler)


    def debug(self, msg, prompt='', quit=False):
        self.logger.debug('(%s) %s' % (prompt, msg) if prompt else msg)
        if quit:
            sys.exit(0)


    def info(self, msg, prompt='', quit=False):
        self.logger.info('(%s) %s' % (prompt, msg) if prompt else msg)
        if quit:
            sys.exit(0)


    def warn(self, msg, prompt='', quit=False):
        self.logger.warn('(%s) %s' % (prompt, msg) if prompt else msg)
        if quit:
            sys.exit(1)


    def error(self, msg, prompt='', quit=False):
        self.logger.error('(%s) %s' % (prompt, msg) if prompt else msg)
        if quit:
            sys.exit(1)
{'fraction_non_alphanumeric': 0.11882022471910113, 'fraction_numerical': 0.0033707865168539327, 'mean_word_length': 2.0592783505154637, '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': '1913896', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1063, 'n_words': 253}