调整日志
This commit is contained in:
@@ -304,7 +304,7 @@ class PluginManager:
|
|||||||
# 修改检查enable状态的代码:遍历所有配置节点
|
# 修改检查enable状态的代码:遍历所有配置节点
|
||||||
for section in plugin._config.values():
|
for section in plugin._config.values():
|
||||||
if isinstance(section, dict) and not section.get("enable", True):
|
if isinstance(section, dict) and not section.get("enable", True):
|
||||||
self.LOG.info(f"PluginManager:插件 {module_name} 已禁用,跳过加载")
|
self.LOG.debug(f"PluginManager:插件 {module_name} 已禁用,跳过加载")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# 初始化插件
|
# 初始化插件
|
||||||
@@ -444,20 +444,20 @@ class PluginManager:
|
|||||||
display_name, plugin = self.find_plugin_by_name(name)
|
display_name, plugin = self.find_plugin_by_name(name)
|
||||||
|
|
||||||
if not plugin:
|
if not plugin:
|
||||||
self.LOG.info(f"PluginManager:插件 {name} 未加载")
|
self.LOG.debug(f"PluginManager:插件 {name} 未加载")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if plugin.status == PluginStatus.RUNNING:
|
if plugin.status == PluginStatus.RUNNING:
|
||||||
self.LOG.info(f"PluginManager:插件 {display_name} 已经在运行")
|
self.LOG.debug(f"PluginManager:插件 {display_name} 已经在运行")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if plugin.start():
|
if plugin.start():
|
||||||
plugin.status = PluginStatus.RUNNING
|
plugin.status = PluginStatus.RUNNING
|
||||||
self.LOG.info(f"PluginManager:插件 {display_name} 状态变更为在运行")
|
self.LOG.debug(f"PluginManager:插件 {display_name} 状态变更为在运行")
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
plugin.status = PluginStatus.ERROR
|
plugin.status = PluginStatus.ERROR
|
||||||
self.LOG.info(f"PluginManager:插件 {display_name} 状态变更为异常")
|
self.LOG.debug(f"PluginManager:插件 {display_name} 状态变更为异常")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def stop_plugin(self, name: str) -> bool:
|
def stop_plugin(self, name: str) -> bool:
|
||||||
@@ -474,20 +474,20 @@ class PluginManager:
|
|||||||
display_name, plugin = self.find_plugin_by_name(name)
|
display_name, plugin = self.find_plugin_by_name(name)
|
||||||
|
|
||||||
if not plugin:
|
if not plugin:
|
||||||
self.LOG.info(f"插件 {name} 未加载")
|
self.LOG.debug(f"插件 {name} 未加载")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if plugin.status != PluginStatus.RUNNING:
|
if plugin.status != PluginStatus.RUNNING:
|
||||||
self.LOG.info(f"插件 {display_name} 未在运行")
|
self.LOG.debug(f"插件 {display_name} 未在运行")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if plugin.stop():
|
if plugin.stop():
|
||||||
plugin.status = PluginStatus.STOPPED
|
plugin.status = PluginStatus.STOPPED
|
||||||
self.LOG.info(f"插件 {display_name} 状态变更为已停止")
|
self.LOG.debug(f"插件 {display_name} 状态变更为已停止")
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
plugin.status = PluginStatus.ERROR
|
plugin.status = PluginStatus.ERROR
|
||||||
self.LOG.info(f"插件 {display_name} 状态变更为异常")
|
self.LOG.debug(f"插件 {display_name} 状态变更为异常")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def shutdown_plugins(self) -> bool:
|
def shutdown_plugins(self) -> bool:
|
||||||
@@ -544,7 +544,7 @@ class PluginManager:
|
|||||||
# 顺便更新映射
|
# 顺便更新映射
|
||||||
if module_name not in self.module_to_display:
|
if module_name not in self.module_to_display:
|
||||||
self.module_to_display[module_name] = display_name
|
self.module_to_display[module_name] = display_name
|
||||||
self.LOG.info(f"PluginManager:添加缺失的模块映射 {module_name} -> {display_name}")
|
self.LOG.debug(f"PluginManager:添加缺失的模块映射 {module_name} -> {display_name}")
|
||||||
return display_name, plugin
|
return display_name, plugin
|
||||||
|
|
||||||
# 不区分大小写比较
|
# 不区分大小写比较
|
||||||
@@ -580,6 +580,6 @@ class PluginManager:
|
|||||||
if hasattr(plugin, "set_bot"):
|
if hasattr(plugin, "set_bot"):
|
||||||
try:
|
try:
|
||||||
plugin.set_bot(bot)
|
plugin.set_bot(bot)
|
||||||
self.LOG.info(f"已成功注入 bot 到插件 {name}")
|
self.LOG.debug(f"已成功注入 bot 到插件 {name}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.LOG.error(f"注入 bot 到插件 {name} 失败: {e}")
|
self.LOG.error(f"注入 bot 到插件 {name} 失败: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user