mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 06:12:53 +08:00
🐛 修复日志功能中的异常处理
This commit is contained in:
parent
3b2273e75b
commit
6120c3bc44
@ -17,6 +17,7 @@ require("nonebot_plugin_apscheduler")
|
||||
require("nonebot_plugin_alconna")
|
||||
require("nonebot_plugin_session")
|
||||
require("nonebot_plugin_saa")
|
||||
require("nonebot_plugin_userinfo")
|
||||
|
||||
from nonebot_plugin_saa import enable_auto_select_bot
|
||||
|
||||
|
||||
@ -100,7 +100,10 @@ class logger:
|
||||
template = cls.__parser_template(
|
||||
info, command, user_id, group_id, adapter, target, platform
|
||||
)
|
||||
logger_.opt(colors=True).info(template)
|
||||
try:
|
||||
logger_.opt(colors=True).info(template)
|
||||
except Exception as e:
|
||||
logger_.info(template)
|
||||
|
||||
@classmethod
|
||||
def success(
|
||||
@ -174,7 +177,10 @@ class logger:
|
||||
)
|
||||
if e:
|
||||
template += f" || 错误<r>{type(e)}: {e}</r>"
|
||||
logger_.opt(colors=True).warning(template)
|
||||
try:
|
||||
logger_.opt(colors=True).warning(template)
|
||||
except Exception as e:
|
||||
logger_.warning(template)
|
||||
|
||||
@overload
|
||||
@classmethod
|
||||
@ -232,7 +238,10 @@ class logger:
|
||||
)
|
||||
if e:
|
||||
template += f" || 错误 <r>{type(e)}: {e}</r>"
|
||||
logger_.opt(colors=True).error(template)
|
||||
try:
|
||||
logger_.opt(colors=True).error(template)
|
||||
except Exception as e:
|
||||
logger_.error(template)
|
||||
|
||||
@overload
|
||||
@classmethod
|
||||
@ -290,7 +299,10 @@ class logger:
|
||||
)
|
||||
if e:
|
||||
template += f" || 错误 <r>{type(e)}: {e}</r>"
|
||||
logger_.opt(colors=True).debug(template)
|
||||
try:
|
||||
logger_.opt(colors=True).debug(template)
|
||||
except Exception as e:
|
||||
logger_.debug(template)
|
||||
|
||||
@classmethod
|
||||
def __parser_template(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user