<commit_before>import collections
import logging
import logging.handlers
import subprocess
import traceback

RunCommandOutput = collections.namedtuple('RunCommandOutput', ['stdout', 'stderr', 'error_level'])


def get_logger(name, max_bytes=16384, backup_count=2):
    """
    this function gets (or creates) a logger for the requested name

    :param name: name of logger to create or get (if it already exists)
    :param max_bytes: size a log file can get to before it rotates
    :param backup_count: number of rotations of a file before deletion (e.g. x.log, x.log.1, x.log.2)
    :return: logger object
    """

    logger = logging.getLogger(name)
    existed = True
    if not logger.handlers:
        existed = False
        logger.setLevel(logging.DEBUG)
        handler = logging.handlers.RotatingFileHandler(
            '/tmp/mac_os_scripts_{0}.log'.format(name),
            maxBytes=max_bytes,
            backupCount=backup_count,
        )

        handler.setFormatter(
            logging.Formatter(
                '%(asctime)s %(levelname)s %(message)s'
            )
        )

        logger.addHandler(handler)

    if existed:
        logger.debug('got existing logger for {0}'.format(name))
    else:
        logger.debug('created new logger for {0}'.format(name))

    return logger


logger = get_logger('utils')


def run_command(command_line, quiet=True):
    """
    this function tries to execute the specified command line<commit_msg>Enabled stdout logging also<commit_after>import collections
import logging
import logging.handlers
import subprocess
import traceback

RunCommandOutput = collections.namedtuple('RunCommandOutput', ['stdout', 'stderr', 'error_level'])


def get_logger(name, max_bytes=16384, backup_count=2, also_stdout=True):
    """
    this function gets (or creates) a logger for the requested name

    :param name: name of logger to create or get (if it already exists)
    :param max_bytes: size a log file can get to before it rotates
    :param backup_count: number of rotations of a file before deletion (e.g. x.log, x.log.1, x.log.2)
    :return: logger object
    """

    logger = logging.getLogger(name)
    existed = True
    if not logger.handlers:
        existed = False
        logger.setLevel(logging.DEBUG)
        handler = logging.handlers.RotatingFileHandler(
            '/tmp/mac_os_scripts_{0}.log'.format(name),
            maxBytes=max_bytes,
            backupCount=backup_count,
        )

        handler.setFormatter(
            logging.Formatter(
                '%(asctime)s %(levelname)s %(message)s'
            )
        )

        logger.addHandler(handler)

        if also_stdout:
            handler = logging.StreamHandler()

            handler.setFormatter(
                logging.Formatter(
                    '%(asctime)s %(levelname)s %(message)s'
                )
            )

            logger.addHandler(handler)

    if existed:
        logger.debug('got existing logger for {0}'.format(name))
    else:
        logger.debug('created new logger for {0}'.format(name))

    return logger


logger = get_logger('utils')


def run_command(command_line, quiet=True):
    """
    this function tries to execute the specified command line
{'fraction_non_alphanumeric': 0.09719222462203024, 'fraction_numerical': 0.006788028386300524, 'mean_word_length': 2.6304591265397534, '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': '4404540', 'n_tokens_mistral': 932, 'n_tokens_neox': 897, 'n_words': 257}