style(log): 统一日志格式,使用文本标签替代emoji前缀

将日志消息中的 emoji 前缀(如 , , ⚠️)替换为更清晰、更易于解析的文本标签(如 [成功], [错误], [警告])。

这一改动有以下好处:
- 提高了在不同终端和环境下的日志可读性与一致性。
- 避免了 emoji 字符可能导致的渲染问题。
- 使日志更易于被自动化工具进行筛选和分析。
This commit is contained in:
minecraft1024a
2025-11-23 14:40:34 +08:00
parent 787b8f01f3
commit 33c6ddc6dd
5 changed files with 19 additions and 19 deletions

View File

@@ -223,7 +223,7 @@ class AffinityInterestCalculator(BaseInterestCalculator):
return 0.0
except asyncio.TimeoutError:
logger.warning("⏱️ 兴趣匹配计算超时(>1.5秒)返回默认分值0.5以保留其他分数")
logger.warning("[超时] 兴趣匹配计算超时(>1.5秒)返回默认分值0.5以保留其他分数")
return 0.5 # 超时时返回默认分值,避免丢失提及分和关系分
except Exception as e:
logger.warning(f"智能兴趣匹配失败: {e}")

View File

@@ -85,14 +85,14 @@ class ProactiveThinkingReplyHandler(BaseEventHandler):
if success:
if was_paused:
logger.info(f" 聊天流 {stream_id} 主动思考已恢复并重置")
logger.info(f"[成功] 聊天流 {stream_id} 主动思考已恢复并重置")
else:
logger.debug(f" 聊天流 {stream_id} 主动思考任务已重置")
logger.debug(f"[成功] 聊天流 {stream_id} 主动思考任务已重置")
else:
logger.warning(f" 重置聊天流 {stream_id} 主动思考任务失败")
logger.warning(f"[错误] 重置聊天流 {stream_id} 主动思考任务失败")
except Exception as e:
logger.error(f" 处理reply事件时出错: {e}", exc_info=True)
logger.error(f"[错误] 处理reply事件时出错: {e}", exc_info=True)
# 总是继续处理其他handler
return HandlerResult(success=True, continue_process=True, message=None)

View File

@@ -694,11 +694,11 @@ async def execute_proactive_thinking(stream_id: str):
# 尝试获取锁,如果已被占用则跳过本次执行(防止重复)
if lock.locked():
logger.warning(f"⚠️ 主动思考跳过:聊天流 {stream_id} 已有正在执行的主动思考任务")
logger.warning(f"[警告] 主动思考跳过:聊天流 {stream_id} 已有正在执行的主动思考任务")
return
async with lock:
logger.debug(f"🤔 开始主动思考 {stream_id}")
logger.debug(f"[思考] 开始主动思考 {stream_id}")
try:
# 0. 前置检查
@@ -709,10 +709,10 @@ async def execute_proactive_thinking(stream_id: str):
chat_stream = await chat_manager.get_stream(stream_id)
if chat_stream and chat_stream.context_manager.context.is_chatter_processing:
logger.warning(f"⚠️ 主动思考等待:聊天流 {stream_id} 的 chatter 正在处理消息等待3秒后重试...")
logger.warning(f"[警告] 主动思考等待:聊天流 {stream_id} 的 chatter 正在处理消息等待3秒后重试...")
await asyncio.sleep(3)
if chat_stream.context_manager.context.is_chatter_processing:
logger.warning(f"⚠️ 主动思考跳过:聊天流 {stream_id} 的 chatter 仍在处理消息")
logger.warning(f"[警告] 主动思考跳过:聊天流 {stream_id} 的 chatter 仍在处理消息")
return
except Exception as e:
logger.warning(f"检查 chatter 处理状态时出错: {e},继续执行")
@@ -781,7 +781,7 @@ async def execute_proactive_thinking(stream_id: str):
return
elif action == "simple_bubble":
logger.info(f"💬 决策:冒个泡。理由:{reasoning}")
logger.info(f"[决策] 决策:冒个泡。理由:{reasoning}")
proactive_thinking_scheduler.record_decision(stream_id, action, reasoning, None)
@@ -793,7 +793,7 @@ async def execute_proactive_thinking(stream_id: str):
stream_id=stream_id,
text=reply,
)
logger.info(" 已发送冒泡消息")
logger.info("[成功] 已发送冒泡消息")
# 增加每日计数
proactive_thinking_scheduler._increment_daily_count(stream_id)

View File

@@ -216,7 +216,7 @@ class ProactiveThinkingScheduler:
return 0.5
except Exception as e:
logger.error(f"[调度器] 获取聊天流 {stream_id} 的 focus_energy 失败: {e}", exc_info=True)
logger.error(f"[调度器] [错误] 获取聊天流 {stream_id} 的 focus_energy 失败: {e}", exc_info=True)
return 0.5
async def schedule_proactive_thinking(self, stream_id: str) -> bool:
@@ -280,7 +280,7 @@ class ProactiveThinkingScheduler:
return True
except Exception as e:
logger.error(f" 创建主动思考任务失败 {stream_id}: {e}", exc_info=True)
logger.error(f"[错误] 创建主动思考任务失败 {stream_id}: {e}", exc_info=True)
return False
async def pause_proactive_thinking(self, stream_id: str, reason: str = "抛出话题") -> bool:
@@ -340,7 +340,7 @@ class ProactiveThinkingScheduler:
return success
except Exception as e:
logger.error(f" 恢复主动思考失败 {stream_id}: {e}", exc_info=True)
logger.error(f"[错误] 恢复主动思考失败 {stream_id}: {e}", exc_info=True)
return False
async def cancel_proactive_thinking(self, stream_id: str) -> bool:
@@ -361,12 +361,12 @@ class ProactiveThinkingScheduler:
self._paused_streams.discard(stream_id)
success = await unified_scheduler.remove_schedule(schedule_id)
logger.debug(f"⏹️ 取消主动思考 {stream_id}")
logger.debug(f"[取消] 取消主动思考 {stream_id}")
return success
except Exception as e:
logger.error(f" 取消主动思考失败 {stream_id}: {e}", exc_info=True)
logger.error(f"[错误] 取消主动思考失败 {stream_id}: {e}", exc_info=True)
return False
async def is_paused(self, stream_id: str) -> bool:
@@ -482,7 +482,7 @@ class ProactiveThinkingScheduler:
minutes = (remaining_seconds % 3600) // 60
time_str = f"{hours}小时{minutes}分钟后"
status = "⏸️ 暂停中" if is_paused else " 活跃"
status = "[暂停] 暂停中" if is_paused else "[活跃] 活跃"
logger.info(
f"[{i:2d}] {status} | {stream_name}\n"

View File

@@ -99,8 +99,8 @@ class UILogHandler(logging.Handler):
if record.levelname == "DEBUG":
return
emoji_map = {"info": "📝", "warning": "⚠️", "error": "", "debug": "🔍"}
formatted_msg = f"{emoji_map.get(ui_level, '📝')} {msg}"
emoji_map = {"info": "", "warning": "", "error": "", "debug": ""}
formatted_msg = msg
self._send_log_with_retry(formatted_msg, ui_level)
# 可选:记录发送状态