<commit_before>import asyncio
import shlex
import re
import json
import logging
from plugin_manager import BasePlugin
from concurrent.futures import CancelledError
from rs_errors import ConsoleCommandSyntaxError
from discord import NotFound, Forbidden
from traceback import format_tb


class ConsoleListener(BasePlugin):
    name = "console"


    async def activate(self):
        self.log_items = {}
        self.run_loop = True
        self.con_commands = {
            "set_config": self._set_config,
            "get_config": self._get_config_cmd,
            "shutdown": self._shutdown,
            "guilds": self._guilds,
            "channels": self._channels,
            "read": self._read,
            "say": self._say,
            "delete_msg": self._delete_msg,
            "help": self._help,
            "exec": self._exec
        }
        base_logger = logging.getLogger()
        self.logger.info("Disabling STDOUT logger and starting console...")
        for h in base_logger.handlers:
            if isinstance(h, logging.StreamHandler):
                base_logger.removeHandler(h)
        self.task = asyncio.ensure_future(self._listen())

    async def deactivate(self):
        self.run_loop = False
        try:
            self.task.cancel()
        except CancelledError:
            pass

    async def _readline(self):
        loop = asyncio.get_event_loop()
        data = await loop.run_in_executor(None, input, ">> ")
        if not isinstance(data, str):
            data = data.decode(encoding="utf-8")<commit_msg>Add allow_stdout_logging option to console<commit_after>import asyncio
import shlex
import re
import json
import logging
from plugin_manager import BasePlugin
from concurrent.futures import CancelledError
from rs_errors import ConsoleCommandSyntaxError
from discord import NotFound, Forbidden
from traceback import format_tb


class ConsoleListener(BasePlugin):
    name = "console"
    default_config = {
        "allow_stdout_logging": False
    }


    async def activate(self):
        self.log_items = {}
        self.run_loop = True
        self.con_commands = {
            "set_config": self._set_config,
            "get_config": self._get_config_cmd,
            "shutdown": self._shutdown,
            "guilds": self._guilds,
            "channels": self._channels,
            "read": self._read,
            "say": self._say,
            "delete_msg": self._delete_msg,
            "help": self._help,
            "exec": self._exec
        }
        if not self.plugin_config.allow_stdout_logging:
            base_logger = logging.getLogger()
            self.logger.info("Disabling STDOUT logger and starting console...")
            for h in base_logger.handlers:
                if isinstance(h, logging.StreamHandler):
                    base_logger.removeHandler(h)
        else:
            self.logger.info("Starting console...")
        self.task = asyncio.ensure_future(self._listen())

    async def deactivate(self):
        self.run_loop = False
        try:
            self.task.cancel()
        except CancelledError:
            pass

    async def _readline(self):
        loop = asyncio.get_event_loop()
        data = await loop.run_in_executor(None, input, ">> ")
        if not isinstance(data, str):
            data = data.decode(encoding="utf-8")
{'fraction_non_alphanumeric': 0.09208158368326334, 'fraction_numerical': 0.0005998800239952009, 'mean_word_length': 2.2441634241245136, 'pattern_counts': {'":': 21, '<': 3, '<?xml version=': 0, '>': 7, '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': '6467173', 'n_tokens_mistral': 929, 'n_tokens_neox': 912, 'n_words': 222}