refactor(plugin): 统一插件日志记录器为 get_logger

将 hello_world_plugin 中直接使用 `logging` 模块的方式,改为从 `src.common.logger` 导入并使用 `get_logger`。

这确保了插件日志与核心应用日志格式和配置的一致性,便于集中管理和问题排查。同时,此举也修正了 Pylance 关于导入顺序的警告。
This commit is contained in:
minecraft1024a
2025-10-25 11:37:14 +08:00
parent 07cf6e4074
commit 577c76b4a4

View File

@@ -1,13 +1,14 @@
import logging
import random
from typing import Any
from src.common.logger import get_logger
# 修正导入路径让Pylance不再抱怨
from src.plugin_system import (
BaseAction,
BaseEventHandler,
BasePlugin,
BasePrompt,
ToolParamType,
BaseTool,
ChatType,
CommandArgs,
@@ -15,10 +16,12 @@ from src.plugin_system import (
ConfigField,
EventType,
PlusCommand,
ToolParamType,
register_plugin,
)
from src.plugin_system.base.base_event import HandlerResult
logger = get_logger("hello_world_plugin")
class StartupMessageHandler(BaseEventHandler):
"""启动时打印消息的事件处理器。"""
@@ -28,7 +31,7 @@ class StartupMessageHandler(BaseEventHandler):
init_subscribe = [EventType.ON_START]
async def execute(self, params: dict) -> HandlerResult:
logging.info("🎉 Hello World 插件已启动,准备就绪!")
logger.info("🎉 Hello World 插件已启动,准备就绪!")
return HandlerResult(success=True, continue_process=True)