mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 18:27:59 -05:00
[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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user