diff --git a/src/common/logger.py b/src/common/logger.py
index 4bdbb5e06..312867c3c 100644
--- a/src/common/logger.py
+++ b/src/common/logger.py
@@ -325,6 +325,24 @@ WILLING_STYLE_CONFIG = {
},
}
+
+MAI_STATE_CONFIG = {
+ "advanced": {
+ "console_format": (
+ "{time:YYYY-MM-DD HH:mm:ss} | "
+ "{level: <8} | "
+ "{extra[module]: <12} | "
+ "麦麦状态 | "
+ "{message}"
+ ),
+ "file_format": "{time:YYYY-MM-DD HH:mm:ss} | {level: <8} | {extra[module]: <15} | 麦麦状态 | {message}",
+ },
+ "simple": {
+ "console_format": "{time:MM-DD HH:mm} | 麦麦状态 | {message}", # noqa: E501
+ "file_format": "{time:YYYY-MM-DD HH:mm:ss} | {level: <8} | {extra[module]: <15} | 麦麦状态 | {message}",
+ },
+}
+
# LPMM配置
LPMM_STYLE_CONFIG = {
"advanced": {
@@ -364,6 +382,7 @@ SUB_HEARTFLOW_STYLE_CONFIG = (
SUB_HEARTFLOW_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else SUB_HEARTFLOW_STYLE_CONFIG["advanced"]
) # noqa: E501
WILLING_STYLE_CONFIG = WILLING_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else WILLING_STYLE_CONFIG["advanced"]
+MAI_STATE_CONFIG = MAI_STATE_CONFIG["simple"] if SIMPLE_OUTPUT else MAI_STATE_CONFIG["advanced"]
CONFIG_STYLE_CONFIG = CONFIG_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else CONFIG_STYLE_CONFIG["advanced"]
TOOL_USE_STYLE_CONFIG = TOOL_USE_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else TOOL_USE_STYLE_CONFIG["advanced"]
PFC_STYLE_CONFIG = PFC_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else PFC_STYLE_CONFIG["advanced"]
diff --git a/src/heart_flow/background_tasks.py b/src/heart_flow/background_tasks.py
index 8538b4c3e..f4f747328 100644
--- a/src/heart_flow/background_tasks.py
+++ b/src/heart_flow/background_tasks.py
@@ -112,7 +112,7 @@ class BackgroundTaskManager:
"""周期性任务主循环"""
while True:
start_time = asyncio.get_event_loop().time()
- logger.debug(f"开始执行后台任务: {task_name}")
+ # logger.debug(f"开始执行后台任务: {task_name}")
try:
await task_func(**kwargs) # 执行实际任务
diff --git a/src/heart_flow/interest_logger.py b/src/heart_flow/interest_logger.py
index d216b6974..ca5d55c6e 100644
--- a/src/heart_flow/interest_logger.py
+++ b/src/heart_flow/interest_logger.py
@@ -49,7 +49,7 @@ class InterestLogger:
logger.debug("未找到任何子心流状态")
return results
- logger.debug(f"正在获取 {len(all_flows)} 个子心流的兴趣状态...")
+ # logger.debug(f"正在获取 {len(all_flows)} 个子心流的兴趣状态...")
for subheartflow in all_flows:
if self.subheartflow_manager.get_subheartflow(subheartflow.subheartflow_id):
tasks.append(
@@ -89,7 +89,7 @@ class InterestLogger:
async def log_interest_states(self):
"""获取所有子心流的兴趣状态并写入日志文件。"""
- logger.debug("开始定期记录兴趣状态...")
+ # logger.debug("开始定期记录兴趣状态...")
try:
current_timestamp = time.time()
all_interest_states = await self.get_all_interest_states()
@@ -128,7 +128,7 @@ class InterestLogger:
}
f.write(json.dumps(log_entry, ensure_ascii=False) + "\n")
count += 1
- logger.debug(f"成功记录 {count} 条兴趣历史到 {self._history_log_file_path}")
+ # logger.debug(f"成功记录 {count} 条兴趣历史到 {self._history_log_file_path}")
except IOError as e:
logger.error(f"写入兴趣历史日志到 {self._history_log_file_path} 出错: {e}")
diff --git a/src/heart_flow/mai_state_manager.py b/src/heart_flow/mai_state_manager.py
index a15f49bc4..86d0aa61c 100644
--- a/src/heart_flow/mai_state_manager.py
+++ b/src/heart_flow/mai_state_manager.py
@@ -2,10 +2,15 @@ import enum
import time
import random
from typing import List, Tuple, Optional
-from src.common.logger import get_module_logger
+from src.common.logger import get_module_logger, LogConfig, MAI_STATE_CONFIG
from src.plugins.moods.moods import MoodManager
-logger = get_module_logger("mai_state_manager")
+mai_state_config = LogConfig(
+ # 使用海马体专用样式
+ console_format=MAI_STATE_CONFIG["console_format"],
+ file_format=MAI_STATE_CONFIG["file_format"],
+)
+logger = get_module_logger("mai_state_manager", config=mai_state_config)
class MaiState(enum.Enum):
diff --git a/src/heart_flow/sub_heartflow.py b/src/heart_flow/sub_heartflow.py
index 92e2aad99..c41200f69 100644
--- a/src/heart_flow/sub_heartflow.py
+++ b/src/heart_flow/sub_heartflow.py
@@ -305,11 +305,11 @@ class SubHeartflow:
await self.heart_fc_instance.shutdown() # 正确关闭 HeartFChatting
self.heart_fc_instance = None
- chat_stream = chat_manager.get_stream(self.chat_id)
- self.normal_chat_instance = NormalChat(
- chat_stream=chat_stream, interest_dict=self.get_interest_dict()
- )
- await self.normal_chat_instance.start_monitoring_interest()
+ chat_stream = chat_manager.get_stream(self.chat_id)
+ self.normal_chat_instance = NormalChat(
+ chat_stream=chat_stream, interest_dict=self.get_interest_dict()
+ )
+ await self.normal_chat_instance.start_monitoring_interest()
# NormalChat 启动/停止逻辑将在下面处理
elif new_state == ChatState.FOCUSED:
diff --git a/src/heart_flow/subheartflow_manager.py b/src/heart_flow/subheartflow_manager.py
index 22ca2546b..4a207f935 100644
--- a/src/heart_flow/subheartflow_manager.py
+++ b/src/heart_flow/subheartflow_manager.py
@@ -66,7 +66,7 @@ class SubHeartflowManager:
subflow.should_stop = False # 重置停止标志
subflow.last_active_time = time.time() # 更新活跃时间
- logger.debug(f"获取到已存在的子心流: {subheartflow_id}")
+ # logger.debug(f"获取到已存在的子心流: {subheartflow_id}")
return subflow
# 创建新的子心流实例