From cc343c981fe1f13aa90f975b55030cb6d3d75cc3 Mon Sep 17 00:00:00 2001 From: yanyongyu Date: Fri, 14 Jan 2022 12:32:03 +0800 Subject: [PATCH] :hankey: add logger format todo --- nonebot/log.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nonebot/log.py b/nonebot/log.py index a1bf7f26..08f54894 100644 --- a/nonebot/log.py +++ b/nonebot/log.py @@ -19,6 +19,8 @@ if TYPE_CHECKING: # because loguru module do not have `Logger` class actually from loguru import Logger + from nonebot.plugin import Plugin + # logger = logging.getLogger("nonebot") logger: "Logger" = loguru.logger """ @@ -48,9 +50,11 @@ class Filter: def __call__(self, record): module_name: str = record["name"] - module = sys.modules.get(module_name) - if module: - module_name = getattr(module, "__module_name__", module_name) + # TODO: get plugin name instead of module name + # module = sys.modules.get(module_name) + # if module and hasattr(module, "__plugin__"): + # plugin: "Plugin" = getattr(module, "__plugin__") + # module_name = plugin.module_name record["name"] = module_name.split(".")[0] levelno = ( logger.level(self.level).no if isinstance(self.level, str) else self.level