🐛 fix log tag unescaped

This commit is contained in:
yanyongyu 2021-07-07 14:08:44 +08:00
parent 3571a5fdc0
commit f42d578765
2 changed files with 3 additions and 3 deletions

View File

@ -9,8 +9,8 @@ import httpx
from nonebot.log import logger from nonebot.log import logger
from nonebot.typing import overrides from nonebot.typing import overrides
from nonebot.message import handle_event from nonebot.message import handle_event
from nonebot.utils import DataclassEncoder
from nonebot.adapters import Bot as BaseBot from nonebot.adapters import Bot as BaseBot
from nonebot.utils import escape_tag, DataclassEncoder
from nonebot.drivers import Driver, HTTPConnection, HTTPRequest, HTTPResponse, WebSocket from nonebot.drivers import Driver, HTTPConnection, HTTPRequest, HTTPResponse, WebSocket
from .utils import log, escape from .utils import log, escape
@ -321,7 +321,7 @@ class Bot(BaseBot):
await handle_event(self, event) await handle_event(self, event)
except Exception as e: except Exception as e:
logger.opt(colors=True, exception=e).error( logger.opt(colors=True, exception=e).error(
f"<r><bg #f8bbd0>Failed to handle event. Raw: {data}</bg #f8bbd0></r>" f"<r><bg #f8bbd0>Failed to handle event. Raw: {escape_tag(data)}</bg #f8bbd0></r>"
) )
@overrides(BaseBot) @overrides(BaseBot)

View File

@ -37,7 +37,7 @@ class Event(BaseEvent):
@overrides(BaseEvent) @overrides(BaseEvent)
def get_event_description(self) -> str: def get_event_description(self) -> str:
return str(self.dict()) return escape_tag(str(self.dict()))
@overrides(BaseEvent) @overrides(BaseEvent)
def get_message(self) -> Message: def get_message(self) -> Message: