更换print到logger
This commit is contained in:
17
main.py
17
main.py
@@ -10,9 +10,11 @@ import time
|
||||
from watchdog.observers import Observer
|
||||
from watchdog.events import FileSystemEventHandler
|
||||
|
||||
# 初始化日志系统,必须在其他 core 模块导入之前执行
|
||||
from core.logger import logger
|
||||
|
||||
from core import WS
|
||||
from core.plugin_manager import load_all_plugins
|
||||
#from core.redis_manager import redis_client
|
||||
|
||||
|
||||
class PluginReloadHandler(FileSystemEventHandler):
|
||||
@@ -55,17 +57,18 @@ class PluginReloadHandler(FileSystemEventHandler):
|
||||
|
||||
self.last_reload_time = current_time
|
||||
|
||||
print(f"\n[HotReload] 检测到文件变更: {event.src_path}")
|
||||
print("[HotReload] 正在重载插件...")
|
||||
logger.info(f"检测到文件变更: {event.src_path}")
|
||||
logger.info("正在重载插件...")
|
||||
|
||||
try:
|
||||
# 重新扫描并加载插件
|
||||
load_all_plugins()
|
||||
print("[HotReload] 插件重载完成")
|
||||
logger.success("插件重载完成")
|
||||
except Exception as e:
|
||||
print(f"[HotReload] 重载失败: {e}")
|
||||
logger.exception(f"重载失败: {e}")
|
||||
|
||||
|
||||
@logger.catch
|
||||
async def main():
|
||||
"""
|
||||
主函数
|
||||
@@ -87,9 +90,9 @@ async def main():
|
||||
if os.path.exists(plugin_path):
|
||||
observer.schedule(event_handler, plugin_path, recursive=True)
|
||||
observer.start()
|
||||
print(f"[HotReload] 已启动插件热重载监控: {plugin_path}")
|
||||
logger.info(f"已启动插件热重载监控: {plugin_path}")
|
||||
else:
|
||||
print(f"[HotReload] 警告: 插件目录不存在 {plugin_path}")
|
||||
logger.warning(f"插件目录不存在 {plugin_path}")
|
||||
|
||||
try:
|
||||
bot = WS()
|
||||
|
||||
Reference in New Issue
Block a user