<commit_before>"""
Implementation of hooks and APIs for outputting log messages.
"""

from __future__ import unicode_literals

from six import text_type as unicode, PY3
if PY3:
    from . import _py3json as json
    pyjson = json
else:
    try:
        # ujson has some issues, in particular it is far too lenient on bad
        # inputs... but on the other hand it's much faster than built-in
        # json module on CPython. So we use it until we come up with some
        # better. We import built-in module for use by the validation code
        # path, since we want to validate messages encode in all JSON
        # encoders.
        import ujson as json
        import json as pyjson
    except ImportError:
        import json
        pyjson = json



from zope.interface import Interface, implementer

from ._traceback import writeTraceback, TRACEBACK_MESSAGE
from ._message import Message
from ._util import saferepr


class Destinations(object):
    """
    Manage a list of destinations for message dictionaries.

    The global instance of this class is where L{Logger} instances will
    send written messages.
    """
    def __init__(self):
        self._destinations = []


    def send(self, message):
        """
        Deliver a message to all destinations.

        @param message: A message dictionary that can be serialized to JSON.
        @type serialize: L{bytes}
        """
        for dest in self._destinations:
            try:
                dest(message)<commit_msg>Address review comment: Fix docstring.<commit_after>"""
Implementation of hooks and APIs for outputting log messages.
"""

from __future__ import unicode_literals

from six import text_type as unicode, PY3
if PY3:
    from . import _py3json as json
    pyjson = json
else:
    try:
        # ujson has some issues, in particular it is far too lenient on bad
        # inputs... but on the other hand it's much faster than built-in
        # json module on CPython. So we use it until we come up with some
        # better. We import built-in module for use by the validation code
        # path, since we want to validate messages encode in all JSON
        # encoders.
        import ujson as json
        import json as pyjson
    except ImportError:
        import json
        pyjson = json



from zope.interface import Interface, implementer

from ._traceback import writeTraceback, TRACEBACK_MESSAGE
from ._message import Message
from ._util import saferepr


class Destinations(object):
    """
    Manage a list of destinations for message dictionaries.

    The global instance of this class is where L{Logger} instances will
    send written messages.
    """
    def __init__(self):
        self._destinations = []


    def send(self, message):
        """
        Deliver a message to all destinations.

        @param message: A message dictionary that can be serialized to JSON.
        @type message: L{dict}
        """
        for dest in self._destinations:
            try:
                dest(message)
{'fraction_non_alphanumeric': 0.056179775280898875, 'fraction_numerical': 0.0019828155981493722, 'mean_word_length': 2.447608200455581, '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': '4499840', 'n_tokens_mistral': 812, 'n_tokens_neox': 778, 'n_words': 365}