From 27be47d23874e8ae5eeed1bb5b777a0dab90e88a Mon Sep 17 00:00:00 2001 From: shtlrs Date: Tue, 13 Feb 2024 22:52:19 +0100 Subject: move logger to its own package This sets the place to centralize all logs configs in its own module --- arthur/bot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'arthur/bot.py') diff --git a/arthur/bot.py b/arthur/bot.py index 8acf6fe..e0caa81 100644 --- a/arthur/bot.py +++ b/arthur/bot.py @@ -9,8 +9,9 @@ from kubernetes_asyncio import config from kubernetes_asyncio.config.kube_config import KUBE_CONFIG_DEFAULT_LOCATION from pydis_core import BotBase -from arthur import exts, logger +from arthur import exts from arthur.config import CONFIG +from arthur.log import logger class KingArthur(BotBase): -- cgit v1.2.3 From a3cb5a51fa0117ee86669d295c92c156d8ec2077 Mon Sep 17 00:00:00 2001 From: shtlrs Date: Wed, 14 Feb 2024 00:55:27 +0100 Subject: catch event errors & push them with custom scope --- arthur/bot.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'arthur/bot.py') diff --git a/arthur/bot.py b/arthur/bot.py index e0caa81..9a51298 100644 --- a/arthur/bot.py +++ b/arthur/bot.py @@ -8,6 +8,7 @@ from discord.ext import commands from kubernetes_asyncio import config from kubernetes_asyncio.config.kube_config import KUBE_CONFIG_DEFAULT_LOCATION from pydis_core import BotBase +from sentry_sdk import push_scope from arthur import exts from arthur.config import CONFIG @@ -61,3 +62,12 @@ class KingArthur(BotBase): return False return CONFIG.devops_role in [r.id for r in user.roles] + + async def on_error(self, event_name: str, *args: Any, **kwargs: Any) -> None: + """Log errors raised in event listeners.""" + with push_scope() as scope: + scope.set_tag("event", event_name) + scope.set_extra("args", args) + scope.set_extra("kwargs", kwargs) + + logger.exception(f"Unhandled exception during event: {event_name}.") -- cgit v1.2.3