mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-28 05:59:10 +08:00
💩 add logger format todo
This commit is contained in:
parent
10395d6bce
commit
cc343c981f
@ -19,6 +19,8 @@ if TYPE_CHECKING:
|
|||||||
# because loguru module do not have `Logger` class actually
|
# because loguru module do not have `Logger` class actually
|
||||||
from loguru import Logger
|
from loguru import Logger
|
||||||
|
|
||||||
|
from nonebot.plugin import Plugin
|
||||||
|
|
||||||
# logger = logging.getLogger("nonebot")
|
# logger = logging.getLogger("nonebot")
|
||||||
logger: "Logger" = loguru.logger
|
logger: "Logger" = loguru.logger
|
||||||
"""
|
"""
|
||||||
@ -48,9 +50,11 @@ class Filter:
|
|||||||
|
|
||||||
def __call__(self, record):
|
def __call__(self, record):
|
||||||
module_name: str = record["name"]
|
module_name: str = record["name"]
|
||||||
module = sys.modules.get(module_name)
|
# TODO: get plugin name instead of module name
|
||||||
if module:
|
# module = sys.modules.get(module_name)
|
||||||
module_name = getattr(module, "__module_name__", module_name)
|
# if module and hasattr(module, "__plugin__"):
|
||||||
|
# plugin: "Plugin" = getattr(module, "__plugin__")
|
||||||
|
# module_name = plugin.module_name
|
||||||
record["name"] = module_name.split(".")[0]
|
record["name"] = module_name.split(".")[0]
|
||||||
levelno = (
|
levelno = (
|
||||||
logger.level(self.level).no if isinstance(self.level, str) else self.level
|
logger.level(self.level).no if isinstance(self.level, str) else self.level
|
||||||
|
Loading…
Reference in New Issue
Block a user