mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -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
|
import discord
|
||||||
from .sentry_setup import should_log
|
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
from . import __version__
|
from . import __version__
|
||||||
@ -134,6 +133,10 @@ def init_events(bot, cli_flags):
|
|||||||
if bot.rpc_enabled:
|
if bot.rpc_enabled:
|
||||||
await initialize(bot)
|
await initialize(bot)
|
||||||
|
|
||||||
|
@bot.event
|
||||||
|
async def on_error(event_method, *args, **kwargs):
|
||||||
|
sentry_log.exception("Exception in on_{}".format(event_method))
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_command_error(ctx, error):
|
async def on_command_error(ctx, error):
|
||||||
if isinstance(error, commands.MissingRequiredArgument):
|
if isinstance(error, commands.MissingRequiredArgument):
|
||||||
@ -166,12 +169,6 @@ def init_events(bot, cli_flags):
|
|||||||
error, error.__traceback__))
|
error, error.__traceback__))
|
||||||
bot._last_exception = exception_log
|
bot._last_exception = exception_log
|
||||||
await ctx.send(inline(message))
|
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):
|
elif isinstance(error, commands.CommandNotFound):
|
||||||
pass
|
pass
|
||||||
elif isinstance(error, commands.CheckFailure):
|
elif isinstance(error, commands.CheckFailure):
|
||||||
@ -185,6 +182,10 @@ def init_events(bot, cli_flags):
|
|||||||
else:
|
else:
|
||||||
log.exception(type(error).__name__, exc_info=error)
|
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
|
@bot.event
|
||||||
async def on_message(message):
|
async def on_message(message):
|
||||||
bot.counter["messages_read"] += 1
|
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 raven.handlers.logging import SentryHandler
|
||||||
|
|
||||||
from redbot.core import __version__
|
from redbot.core import __version__
|
||||||
|
|
||||||
__all__ = ("init_sentry_logging", "should_log")
|
__all__ = ("init_sentry_logging",)
|
||||||
|
|
||||||
|
|
||||||
include_paths = (
|
include_paths = (
|
||||||
'core',
|
'redbot',
|
||||||
'cogs.alias',
|
|
||||||
'cogs.audio',
|
|
||||||
'cogs.downloader',
|
|
||||||
'cogs.economy',
|
|
||||||
'cogs.general',
|
|
||||||
'cogs.image',
|
|
||||||
'cogs.streams',
|
|
||||||
'cogs.trivia',
|
|
||||||
'cogs.utils',
|
|
||||||
'tests.core.test_sentry',
|
|
||||||
'main',
|
|
||||||
'launcher'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
client = None
|
client = None
|
||||||
@ -30,14 +18,9 @@ def init_sentry_logging(logger):
|
|||||||
client = Client(
|
client = Client(
|
||||||
dsn=("https://62402161d4cd4ef18f83b16f3e22a020:9310ef55a502442598203205a84da2bb@"
|
dsn=("https://62402161d4cd4ef18f83b16f3e22a020:9310ef55a502442598203205a84da2bb@"
|
||||||
"sentry.io/253983"),
|
"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)
|
handler = SentryHandler(client)
|
||||||
logger.addHandler(handler)
|
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