<commit_before>"""
A simple logging object. It reports, with
the help of the Compositor objects, a
wide range of data about the processing
of a string of text for a font.

Usage:

    logger = Logger()
    logger.logStart()
    font = Font("/path/to/a/font.otf")
    font.process("Hello World!", logger=logger)
    logger.logEnd()
    report = logger.getText()

The returned log is in XML format.
"""

from fontTools.misc.py23 import StringIO
from xmlWriter import XMLWriter


class Logger(object):

    def __init__(self):
        self._file = StringIO()
        self._writer = XMLWriter(self._file, encoding="utf-8")

    def __del__(self):
        self._writer = None
        self._file.close()
<commit_msg>xml writer moved<commit_after>"""
A simple logging object. It reports, with
the help of the Compositor objects, a
wide range of data about the processing
of a string of text for a font.

Usage:

    logger = Logger()
    logger.logStart()
    font = Font("/path/to/a/font.otf")
    font.process("Hello World!", logger=logger)
    logger.logEnd()
    report = logger.getText()

The returned log is in XML format.
"""

from fontTools.misc.py23 import StringIO
from fontTools.misc.xmlWriter import XMLWriter


class Logger(object):

    def __init__(self):
        self._file = StringIO()
        self._writer = XMLWriter(self._file, encoding="utf-8")

    def __del__(self):
        self._writer = None
        self._file.close()

{'fraction_non_alphanumeric': 0.10848400556328233, 'fraction_numerical': 0.004172461752433936, 'mean_word_length': 3.1469740634005765, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 3}, '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': '6504812', 'n_tokens_mistral': 441, 'n_tokens_neox': 427, 'n_words': 144}