mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-01-19 09:38:21 +08:00
Merge pull request #334 from nonebot/yanyongyu/issue332
Fix: log module name error
This commit is contained in:
commit
4ba6ff106c
@ -48,6 +48,10 @@ class Filter:
|
||||
self.level: Union[int, str] = "DEBUG"
|
||||
|
||||
def __call__(self, record):
|
||||
module = sys.modules.get(record["name"])
|
||||
if module:
|
||||
plugin_name = getattr(module, "__plugin_name__", record["name"])
|
||||
record["name"] = plugin_name
|
||||
record["name"] = record["name"].split(".")[0]
|
||||
levelno = logger.level(self.level).no if isinstance(self.level,
|
||||
str) else self.level
|
||||
|
@ -215,6 +215,9 @@ class PluginLoader(SourceFileLoader):
|
||||
return
|
||||
# really need?
|
||||
# setattr(module, "__manager__", self.manager)
|
||||
if self._plugin_token:
|
||||
setattr(module, "__plugin_name__",
|
||||
_current_plugin.get(self._plugin_token))
|
||||
if self._export_token:
|
||||
setattr(module, "__export__", _export.get())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user