mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[V3 Sentry] Fix sentry logging (#1169)
This commit is contained in:
parent
b34a58e521
commit
be591d7c65
@ -8,7 +8,6 @@ from pkg_resources import DistributionNotFound
|
||||
|
||||
|
||||
import discord
|
||||
from .sentry_setup import should_log
|
||||
from discord.ext import commands
|
||||
|
||||
from . import __version__
|
||||
@ -134,6 +133,10 @@ def init_events(bot, cli_flags):
|
||||
if bot.rpc_enabled:
|
||||
await initialize(bot)
|
||||
|
||||
@bot.event
|
||||
async def on_error(event_method, *args, **kwargs):
|
||||
sentry_log.exception("Exception in on_{}".format(event_method))
|
||||
|
||||
@bot.event
|
||||
async def on_command_error(ctx, error):
|
||||
if isinstance(error, commands.MissingRequiredArgument):
|
||||
@ -166,12 +169,6 @@ def init_events(bot, cli_flags):
|
||||
error, error.__traceback__))
|
||||
bot._last_exception = exception_log
|
||||
await ctx.send(inline(message))
|
||||
|
||||
module = ctx.command.module
|
||||
if should_log(module):
|
||||
sentry_log.exception("Exception in command '{}'"
|
||||
"".format(ctx.command.qualified_name),
|
||||
exc_info=error.original)
|
||||
elif isinstance(error, commands.CommandNotFound):
|
||||
pass
|
||||
elif isinstance(error, commands.CheckFailure):
|
||||
@ -185,6 +182,10 @@ def init_events(bot, cli_flags):
|
||||
else:
|
||||
log.exception(type(error).__name__, exc_info=error)
|
||||
|
||||
sentry_log.exception("Exception in command '{}'"
|
||||
"".format(ctx.command.qualified_name),
|
||||
exc_info=error.original)
|
||||
|
||||
@bot.event
|
||||
async def on_message(message):
|
||||
bot.counter["messages_read"] += 1
|
||||
|
||||
@ -1,25 +1,13 @@
|
||||
from raven import Client, breadcrumbs
|
||||
from raven import Client
|
||||
from raven.handlers.logging import SentryHandler
|
||||
|
||||
from redbot.core import __version__
|
||||
|
||||
__all__ = ("init_sentry_logging", "should_log")
|
||||
__all__ = ("init_sentry_logging",)
|
||||
|
||||
|
||||
include_paths = (
|
||||
'core',
|
||||
'cogs.alias',
|
||||
'cogs.audio',
|
||||
'cogs.downloader',
|
||||
'cogs.economy',
|
||||
'cogs.general',
|
||||
'cogs.image',
|
||||
'cogs.streams',
|
||||
'cogs.trivia',
|
||||
'cogs.utils',
|
||||
'tests.core.test_sentry',
|
||||
'main',
|
||||
'launcher'
|
||||
'redbot',
|
||||
)
|
||||
|
||||
client = None
|
||||
@ -30,14 +18,9 @@ def init_sentry_logging(logger):
|
||||
client = Client(
|
||||
dsn=("https://62402161d4cd4ef18f83b16f3e22a020:9310ef55a502442598203205a84da2bb@"
|
||||
"sentry.io/253983"),
|
||||
release=__version__
|
||||
release=__version__,
|
||||
include_paths=['redbot'],
|
||||
enable_breadcrumbs=False
|
||||
)
|
||||
|
||||
breadcrumbs.ignore_logger("websockets")
|
||||
breadcrumbs.ignore_logger("websockets.protocol")
|
||||
handler = SentryHandler(client)
|
||||
logger.addHandler(handler)
|
||||
|
||||
|
||||
def should_log(module_name: str) -> bool:
|
||||
return any(module_name.startswith(path) for path in include_paths)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user