From 43b185a3b8504a4030e8b897a98b443c17cbe8ef Mon Sep 17 00:00:00 2001 From: yanyongyu Date: Sat, 27 Mar 2021 14:42:43 +0800 Subject: [PATCH] :loud_sound: add log for event handle --- nonebot/message.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nonebot/message.py b/nonebot/message.py index cc226875..469b1df2 100644 --- a/nonebot/message.py +++ b/nonebot/message.py @@ -205,7 +205,8 @@ async def handle_event(bot: "Bot", event: "Event"): coros = list(map(lambda x: x(bot, event, state), _event_preprocessors)) if coros: try: - logger.debug("Running PreProcessors...") + if show_log: + logger.debug("Running PreProcessors...") await asyncio.gather(*coros) except IgnoredException: logger.opt(colors=True).info( @@ -240,11 +241,16 @@ async def handle_event(bot: "Bot", event: "Event"): if not break_flag: break_flag = True logger.debug("Stop event propagation") + elif isinstance(result, Exception): + logger.opt(colors=True, exception=result).error( + "Error when checking Matcher." + ) coros = list(map(lambda x: x(bot, event, state), _event_postprocessors)) if coros: try: - logger.debug("Running PostProcessors...") + if show_log: + logger.debug("Running PostProcessors...") await asyncio.gather(*coros) except Exception as e: logger.opt(colors=True, exception=e).error(