[V3 Sentry] Allow toggling of Sentry logging (#1214)

* Refactor sentry to allow toggle

* Rename sentry module

* Protect sentry manager

* Fix tests

* Fix EOF newlines

* Add docstrings
This commit is contained in:
Tobotimus
2018-01-15 15:26:26 +11:00
committed by GitHub
parent e18f94c17d
commit 73c08da037
6 changed files with 70 additions and 34 deletions

View File

@@ -1,5 +1,6 @@
import asyncio
import os
import logging
from collections import Counter
from enum import Enum
from importlib.machinery import ModuleSpec
@@ -17,7 +18,7 @@ from . import (
rpc
)
from .help_formatter import Help, help as help_
from .sentry import SentryManager
from .utils import TYPE_CHECKING
if TYPE_CHECKING:
@@ -102,6 +103,22 @@ class RedBase(BotBase, RpcMethodMixin):
self.add_command(help_)
self._sentry_mgr = None
def enable_sentry(self):
"""Enable Sentry logging for Red."""
if self._sentry_mgr is None:
sentry_log = logging.getLogger('red.sentry')
sentry_log.setLevel(logging.WARNING)
self._sentry_mgr = SentryManager(sentry_log)
self._sentry_mgr.enable()
def disable_sentry(self):
"""Disable Sentry logging for Red."""
if self._sentry_mgr is None:
return
self._sentry_mgr.disable()
async def _dict_abuse(self, indict):
"""
Please blame <@269933075037814786> for this.