<commit_before>import multiprocessing
import sys
import logging as log
from serialProcess import SerialProcess

TIMEOUT = 1000


def main():
    result_queue = multiprocessing.Queue()

    sp = SerialProcess(result_queue)
    ports = sp.get_ports()
    log.info(ports)
    if 0 < len(ports):
        sp.open_port(ports[0])
        if sp.is_port_available(ports[0]):
            sp.start()
            value = result_queue.get(block=True, timeout=TIMEOUT)
            count = 0
            while count < 5:
                if not result_queue.empty():
                    print(value)
                    value = result_queue.get(block=False)
                    count = value[1]
            sp.stop()
            sp.join()
        else:
            log.info("Port is not available")
    else:
        log.warning("No ports detected")


def start_logging():
    log_format = log.Formatter('%(asctime)s %(levelname)s %(message)s')
    logger = log.getLogger('__name__')
    logger.setLevel(log.INFO)

    file_handler = log.FileHandler("RTGraph.log")
    file_handler.setFormatter(log_format)
    logger.addHandler(file_handler)

    console_handler = log.StreamHandler()
    console_handler.setFormatter(log_format)
    logger.addHandler(console_handler)


if __name__ == '__main__':
    multiprocessing.freeze_support()
    start_logging()

    log.info("Starting RTGraph")
    main()
    log.info("Finishing RTGraph")
    sys.exit()
<commit_msg>using RotatingFileHandlers for the loggers<commit_after>import multiprocessing
import sys
import logging as log
import logging.handlers
from serialProcess import SerialProcess

TIMEOUT = 1000


def main():
    result_queue = multiprocessing.Queue()

    sp = SerialProcess(result_queue)
    ports = sp.get_ports()
    log.info(ports)
    if 0 < len(ports):
        sp.open_port(ports[0])
        if sp.is_port_available(ports[0]):
            sp.start()
            value = result_queue.get(block=True, timeout=TIMEOUT)
            count = 0
            while count < 5:
                if not result_queue.empty():
                    print(value)
                    value = result_queue.get(block=False)
                    count = value[1] * 1000
            sp.stop()
            sp.join()
        else:
            log.info("Port is not available")
    else:
        log.warning("No ports detected")


def start_logging():
    log_format = log.Formatter('%(asctime)s,%(levelname)s,%(message)s')
    logger = log.getLogger()
    logger.setLevel(log.INFO)

    # file_handler = log.FileHandler("RTGraph.log")
    file_handler = logging.handlers.RotatingFileHandler("RTGraph.log", maxBytes=1024, backupCount=3)
    file_handler.setFormatter(log_format)
    logger.addHandler(file_handler)

    console_handler = log.StreamHandler(sys.stdout)
    console_handler.setFormatter(log_format)
    logger.addHandler(console_handler)


if __name__ == '__main__':
    multiprocessing.freeze_support()
    start_logging()

    log.info("Starting RTGraph")
    main()
    log.info("Finishing RTGraph")
    sys.exit()

{'fraction_non_alphanumeric': 0.10801963993453355, 'fraction_numerical': 0.009492635024549919, 'mean_word_length': 2.5868544600938965, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6142697', 'n_tokens_mistral': 955, 'n_tokens_neox': 907, 'n_words': 179}