[V3 Sentry] Fix sentry logging (#1169)

This commit is contained in:
Will
2017-12-12 22:34:34 -05:00
committed by GitHub
parent b34a58e521
commit be591d7c65
2 changed files with 14 additions and 30 deletions

View File

@@ -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