mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-28 02:55:18 +08:00
🔊 Feature: 优化插件加载日志 (#1716)
This commit is contained in:
parent
97723a0838
commit
728902bfcf
@ -148,14 +148,21 @@ class PluginManager:
|
|||||||
else:
|
else:
|
||||||
raise RuntimeError(f"Plugin not found: {name}! Check your plugin name")
|
raise RuntimeError(f"Plugin not found: {name}! Check your plugin name")
|
||||||
|
|
||||||
logger.opt(colors=True).success(
|
if (
|
||||||
f'Succeeded to import "<y>{escape_tag(name)}</y>"'
|
plugin := getattr(module, "__plugin__", None)
|
||||||
)
|
) is None or not isinstance(plugin, Plugin):
|
||||||
if (plugin := getattr(module, "__plugin__", None)) is None:
|
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
f"Module {module.__name__} is not loaded as a plugin! "
|
f"Module {module.__name__} is not loaded as a plugin! "
|
||||||
"Make sure not to import it before loading."
|
"Make sure not to import it before loading."
|
||||||
)
|
)
|
||||||
|
logger.opt(colors=True).success(
|
||||||
|
f'Succeeded to load plugin "<y>{escape_tag(plugin.name)}</y>"'
|
||||||
|
+ (
|
||||||
|
f' from "<m>{escape_tag(plugin.module_name)}</m>"'
|
||||||
|
if plugin.module_name != plugin.name
|
||||||
|
else ""
|
||||||
|
)
|
||||||
|
)
|
||||||
return plugin
|
return plugin
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.opt(colors=True, exception=e).error(
|
logger.opt(colors=True, exception=e).error(
|
||||||
|
Loading…
Reference in New Issue
Block a user