<commit_before>"""Handle logs displayed by Kytos SDN Platform."""
import inspect
import re
from configparser import RawConfigParser
from logging import Formatter, StreamHandler, config, getLogger

__all__ = ('LogManager', 'NAppLog')


class LogManager:
    """Manage handlers for all loggers."""

    configuration = None

    @classmethod
    def load_logging_file(cls, logging_file):
        """Loadding logs configuration from a file.

        Args:
           logging_file(str): Address of logging configuration file.
        """
        cls.configuration = RawConfigParser()
        cls.configuration.read(logging_file)

        try:
            config.fileConfig(logging_file)
        except FileNotFoundError:
            cls.configuration.set('handler_syslog', 'args', '[]')
            config.fileConfig(cls.configuration)

            log = getLogger(__name__)
            msg = 'Syslog file not found, running Kytos without syslog.'
            log.warning(msg)

    @classmethod
    def add_stream_handler(cls, stream):
        """Output all logs to the given stream.

        Args:<commit_msg>Do not disable any logger<commit_after>"""Handle logs displayed by Kytos SDN Platform."""
import inspect
import re
from configparser import RawConfigParser
from logging import Formatter, StreamHandler, config, getLogger

__all__ = ('LogManager', 'NAppLog')


class LogManager:
    """Manage handlers for all loggers."""

    configuration = None

    @classmethod
    def load_logging_file(cls, logging_file):
        """Loadding logs configuration from a file.

        Args:
           logging_file(str): Address of logging configuration file.
        """
        cls.configuration = RawConfigParser()
        cls.configuration.read(logging_file)

        try:
            config.fileConfig(logging_file, disable_existing_loggers=False)
        except FileNotFoundError:
            cls.configuration.set('handler_syslog', 'args', '[]')
            config.fileConfig(cls.configuration)

            log = getLogger(__name__)
            msg = 'Syslog file not found, running Kytos without syslog.'
            log.warning(msg)

    @classmethod
    def add_stream_handler(cls, stream):
        """Output all logs to the given stream.

        Args:
{'fraction_non_alphanumeric': 0.08865248226950355, 'fraction_numerical': 0.0, 'mean_word_length': 2.7869127516778525, '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': '4848638', 'n_tokens_mistral': 592, 'n_tokens_neox': 573, 'n_words': 174}