From 33c6ddc6dd4fdda5f10673861c2fca9683bac520 Mon Sep 17 00:00:00 2001 From: minecraft1024a Date: Sun, 23 Nov 2025 14:40:34 +0800 Subject: [PATCH] =?UTF-8?q?style(log):=20=E7=BB=9F=E4=B8=80=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=A0=BC=E5=BC=8F=EF=BC=8C=E4=BD=BF=E7=94=A8=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E6=A0=87=E7=AD=BE=E6=9B=BF=E4=BB=A3emoji=E5=89=8D?= =?UTF-8?q?=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将日志消息中的 emoji 前缀(如 ✅, ❌, ⚠️)替换为更清晰、更易于解析的文本标签(如 [成功], [错误], [警告])。 这一改动有以下好处: - 提高了在不同终端和环境下的日志可读性与一致性。 - 避免了 emoji 字符可能导致的渲染问题。 - 使日志更易于被自动化工具进行筛选和分析。 --- .../core/affinity_interest_calculator.py | 2 +- .../proactive/proactive_thinking_event.py | 8 ++++---- .../proactive/proactive_thinking_executor.py | 12 ++++++------ .../proactive/proactive_thinking_scheduler.py | 12 ++++++------ ui_log_adapter.py | 4 ++-- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/plugins/built_in/affinity_flow_chatter/core/affinity_interest_calculator.py b/src/plugins/built_in/affinity_flow_chatter/core/affinity_interest_calculator.py index 66ba4cee5..60731ca9c 100644 --- a/src/plugins/built_in/affinity_flow_chatter/core/affinity_interest_calculator.py +++ b/src/plugins/built_in/affinity_flow_chatter/core/affinity_interest_calculator.py @@ -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}") diff --git a/src/plugins/built_in/affinity_flow_chatter/proactive/proactive_thinking_event.py b/src/plugins/built_in/affinity_flow_chatter/proactive/proactive_thinking_event.py index 0d3f39aa8..21af4537d 100644 --- a/src/plugins/built_in/affinity_flow_chatter/proactive/proactive_thinking_event.py +++ b/src/plugins/built_in/affinity_flow_chatter/proactive/proactive_thinking_event.py @@ -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) diff --git a/src/plugins/built_in/affinity_flow_chatter/proactive/proactive_thinking_executor.py b/src/plugins/built_in/affinity_flow_chatter/proactive/proactive_thinking_executor.py index e5b37e58b..fd4296d2a 100644 --- a/src/plugins/built_in/affinity_flow_chatter/proactive/proactive_thinking_executor.py +++ b/src/plugins/built_in/affinity_flow_chatter/proactive/proactive_thinking_executor.py @@ -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) diff --git a/src/plugins/built_in/affinity_flow_chatter/proactive/proactive_thinking_scheduler.py b/src/plugins/built_in/affinity_flow_chatter/proactive/proactive_thinking_scheduler.py index 61c0e4146..c38a2c680 100644 --- a/src/plugins/built_in/affinity_flow_chatter/proactive/proactive_thinking_scheduler.py +++ b/src/plugins/built_in/affinity_flow_chatter/proactive/proactive_thinking_scheduler.py @@ -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" diff --git a/ui_log_adapter.py b/ui_log_adapter.py index d72c94352..bc52d4826 100644 --- a/ui_log_adapter.py +++ b/ui_log_adapter.py @@ -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) # 可选:记录发送状态