🔊 add log for event handle

This commit is contained in:
yanyongyu 2021-03-27 14:42:43 +08:00
parent 65ec4828a9
commit 43b185a3b8

View File

@ -205,7 +205,8 @@ async def handle_event(bot: "Bot", event: "Event"):
coros = list(map(lambda x: x(bot, event, state), _event_preprocessors)) coros = list(map(lambda x: x(bot, event, state), _event_preprocessors))
if coros: if coros:
try: try:
logger.debug("Running PreProcessors...") if show_log:
logger.debug("Running PreProcessors...")
await asyncio.gather(*coros) await asyncio.gather(*coros)
except IgnoredException: except IgnoredException:
logger.opt(colors=True).info( logger.opt(colors=True).info(
@ -240,11 +241,16 @@ async def handle_event(bot: "Bot", event: "Event"):
if not break_flag: if not break_flag:
break_flag = True break_flag = True
logger.debug("Stop event propagation") logger.debug("Stop event propagation")
elif isinstance(result, Exception):
logger.opt(colors=True, exception=result).error(
"<r><bg #f8bbd0>Error when checking Matcher.</bg #f8bbd0></r>"
)
coros = list(map(lambda x: x(bot, event, state), _event_postprocessors)) coros = list(map(lambda x: x(bot, event, state), _event_postprocessors))
if coros: if coros:
try: try:
logger.debug("Running PostProcessors...") if show_log:
logger.debug("Running PostProcessors...")
await asyncio.gather(*coros) await asyncio.gather(*coros)
except Exception as e: except Exception as e:
logger.opt(colors=True, exception=e).error( logger.opt(colors=True, exception=e).error(