diff --git a/src/plugins/nonebot_plugin_sentry/README.md b/src/plugins/nonebot_plugin_sentry/README.md index e8bb3b30..7bff4c4f 100644 --- a/src/plugins/nonebot_plugin_sentry/README.md +++ b/src/plugins/nonebot_plugin_sentry/README.md @@ -2,11 +2,13 @@ * @Author : yanyongyu * @Date : 2020-11-23 20:23:12 * @LastEditors : yanyongyu - * @LastEditTime : 2023-10-02 16:44:50 + * @LastEditTime : 2023-10-18 10:29:34 * @Description : None * @GitHub : https://github.com/yanyongyu --> + +

nonebot @@ -40,6 +42,6 @@ _✨ 在 Sentry.io 上进行 NoneBot 服务日志查看、错误处理 ✨_ ## 配置项 -配置项需要添加前缀 `sentry_`,所有参数以及具体含义参考: [Sentry Docs](https://docs.sentry.io/platforms/python/configuration/options/) +配置项需要添加前缀 `SENTRY_`,所有参数以及具体含义参考: [Sentry Docs](https://docs.sentry.io/platforms/python/configuration/options/) -所有以 `sentry_` 开头的配置项将会被自动读取。 +所有以 `SENTRY_` 开头的配置项将会被自动读取。 diff --git a/src/plugins/nonebot_plugin_sentry/__init__.py b/src/plugins/nonebot_plugin_sentry/__init__.py index 0407ddf1..00f59e8c 100644 --- a/src/plugins/nonebot_plugin_sentry/__init__.py +++ b/src/plugins/nonebot_plugin_sentry/__init__.py @@ -2,7 +2,7 @@ @Author : yanyongyu @Date : 2020-11-23 18:44:25 @LastEditors : yanyongyu -@LastEditTime : 2023-10-02 17:07:39 +@LastEditTime : 2023-10-18 10:32:17 @Description : Sentry plugin @GitHub : https://github.com/yanyongyu """ @@ -11,7 +11,6 @@ import sentry_sdk from nonebot import logger, get_driver from nonebot.plugin import PluginMetadata -from sentry_sdk.integrations.logging import EventHandler, BreadcrumbHandler from .config import Config @@ -34,15 +33,8 @@ def init_sentry(config: Config): sentry_config = {key[7:]: value for key, value in config.dict().items()} sentry_sdk.init(**sentry_config) - logger.add( - EventHandler("ERROR"), - filter=lambda r: r["level"].no >= logger.level("ERROR").no, - ) - logger.add( - BreadcrumbHandler("INFO"), - filter=lambda r: r["level"].no >= logger.level("INFO").no, - ) - if config.sentry_dsn: init_sentry(config) +else: + logger.warning("Sentry DSN not provided! Sentry plugin disabled!") diff --git a/src/plugins/nonebot_plugin_sentry/config.py b/src/plugins/nonebot_plugin_sentry/config.py index e62c57e7..1078320d 100644 --- a/src/plugins/nonebot_plugin_sentry/config.py +++ b/src/plugins/nonebot_plugin_sentry/config.py @@ -2,7 +2,7 @@ @Author : yanyongyu @Date : 2020-11-23 18:44:18 @LastEditors : yanyongyu -@LastEditTime : 2023-10-11 11:24:03 +@LastEditTime : 2023-10-18 10:32:28 @Description : Config for Sentry plugin @GitHub : https://github.com/yanyongyu """ @@ -10,7 +10,7 @@ from typing import Any, Dict, List, Optional -from nonebot import logger, get_driver +from nonebot import get_driver from sentry_sdk.integrations import Integration from sentry_sdk.integrations.loguru import LoguruIntegration from pydantic import Extra, Field, BaseModel, validator, root_validator @@ -36,12 +36,6 @@ def filter_sentry_configs(cls, values: Dict[str, Any]): key: value for key, value in values.items() if key.startswith("sentry_") } - @validator("sentry_dsn", allow_reuse=True) - def validate_dsn(cls, v: Optional[str]): - if not v: - logger.warning("Sentry DSN not provided! Sentry plugin disabled!") - return v - @validator("sentry_integrations", allow_reuse=True) def validate_integrations(cls, v: List[Integration]): ids = {i.identifier for i in v}