feat(context_manager): 移除消息添加和标记已读的日志记录,简化代码
This commit is contained in:
@@ -83,11 +83,6 @@ class SingleStreamContextManager:
|
||||
self.total_messages += 1
|
||||
self.last_access_time = time.time()
|
||||
|
||||
# 记录消息添加日志
|
||||
msg_preview = message.processed_plain_text[:30] if message.processed_plain_text else "(无内容)"
|
||||
msg_id_str = str(message.message_id)[:8] if message.message_id else "unknown"
|
||||
logger.info(f"➕ [添加消息] {msg_id_str}: {msg_preview}..., 当前未读数: {len(self.context.unread_messages)}, 历史数: {len(self.context.history_messages)}")
|
||||
|
||||
# 如果使用了缓存系统,输出调试信息
|
||||
if cache_enabled and self.context.is_cache_enabled:
|
||||
if self.context.is_chatter_processing:
|
||||
|
||||
@@ -91,7 +91,6 @@ class MessageManager:
|
||||
|
||||
async def add_message(self, stream_id: str, message: DatabaseMessages):
|
||||
"""添加消息到指定聊天流"""
|
||||
|
||||
try:
|
||||
# 检查是否为notice消息
|
||||
if self._is_notice_message(message):
|
||||
|
||||
@@ -211,10 +211,10 @@ class StatisticOutputTask(AsyncTask):
|
||||
try:
|
||||
now = datetime.now()
|
||||
logger.info("正在收集统计数据(异步)...")
|
||||
stats = await self._collect_all_statistics(now)
|
||||
stats = await asyncio.create_task(self._collect_all_statistics(now))
|
||||
logger.info("统计数据收集完成")
|
||||
self._statistic_console_output(stats, now)
|
||||
await self._generate_html_report(stats, now)
|
||||
self._statistic_console_output(stats, n ow)
|
||||
await asyncio.create_task(self._generate_html_report(stats, now))
|
||||
logger.info("统计数据输出完成")
|
||||
except Exception as e:
|
||||
logger.exception(f"输出统计数据过程中发生异常,错误信息:{e}")
|
||||
|
||||
@@ -98,10 +98,7 @@ class StreamContext(BaseDataModel):
|
||||
break
|
||||
|
||||
def mark_message_as_read(self, message_id: str):
|
||||
"""标记消息为已读"""
|
||||
from src.common.logger import get_logger
|
||||
logger = get_logger("StreamContext")
|
||||
|
||||
"""标记消息为已读"""
|
||||
# 先找到要标记的消息(处理 int/str 类型不匹配问题)
|
||||
message_to_mark = None
|
||||
for msg in self.unread_messages:
|
||||
@@ -115,11 +112,6 @@ class StreamContext(BaseDataModel):
|
||||
message_to_mark.is_read = True
|
||||
self.history_messages.append(message_to_mark)
|
||||
self.unread_messages.remove(message_to_mark)
|
||||
msg_id_str = str(message_id)[:8] if message_id else "unknown"
|
||||
logger.info(f"📌 [标记已读] 消息 {msg_id_str} 已移至历史, 当前历史数: {len(self.history_messages)}, 未读数: {len(self.unread_messages)}")
|
||||
else:
|
||||
msg_id_str = str(message_id)[:8] if message_id else "unknown"
|
||||
logger.warning(f"⚠️ [标记已读] 未找到消息 {msg_id_str} 在未读列表中, 当前未读消息ID列表: {[str(m.message_id)[:8] for m in self.unread_messages[:5]]}")
|
||||
|
||||
def get_unread_messages(self) -> list["DatabaseMessages"]:
|
||||
"""获取未读消息"""
|
||||
|
||||
Reference in New Issue
Block a user