Fixed the Issue Where the Host Information was not Displayed
This commit is contained in:
@@ -377,34 +377,42 @@ def parse_forum_log_line(line):
|
|||||||
"""解析forum.log行内容,提取对话信息"""
|
"""解析forum.log行内容,提取对话信息"""
|
||||||
import re
|
import re
|
||||||
|
|
||||||
# 匹配格式: [时间] [来源] 内容
|
# 匹配格式: [时间] [来源] 内容(来源允许大小写及空格)
|
||||||
pattern = r'\[(\d{2}:\d{2}:\d{2})\]\s*\[([A-Z]+)\]\s*(.*)'
|
pattern = r'\[(\d{2}:\d{2}:\d{2})\]\s*\[([^\]]+)\]\s*(.*)'
|
||||||
match = re.match(pattern, line)
|
match = re.match(pattern, line)
|
||||||
|
|
||||||
if match:
|
if not match:
|
||||||
timestamp, source, content = match.groups()
|
return None
|
||||||
|
|
||||||
# 过滤掉系统消息和空内容
|
timestamp, raw_source, content = match.groups()
|
||||||
if source == 'SYSTEM' or not content.strip():
|
source = raw_source.strip().upper()
|
||||||
return None
|
|
||||||
|
# 过滤掉系统消息和空内容
|
||||||
# 只处理三个Engine的消息
|
if source == 'SYSTEM' or not content.strip():
|
||||||
if source not in ['QUERY', 'INSIGHT', 'MEDIA']:
|
return None
|
||||||
return None
|
|
||||||
|
|
||||||
# 根据来源确定消息类型和发送者
|
|
||||||
message_type = 'agent'
|
|
||||||
sender = f'{source} Engine'
|
|
||||||
|
|
||||||
return {
|
|
||||||
'type': message_type,
|
|
||||||
'sender': sender,
|
|
||||||
'content': content.strip(),
|
|
||||||
'timestamp': timestamp,
|
|
||||||
'source': source
|
|
||||||
}
|
|
||||||
|
|
||||||
return None
|
# 支持三个Agent和主持人
|
||||||
|
if source not in ['QUERY', 'INSIGHT', 'MEDIA', 'HOST']:
|
||||||
|
return None
|
||||||
|
|
||||||
|
# 解码日志中的转义换行,保留多行格式
|
||||||
|
cleaned_content = content.replace('\\n', '\n').replace('\\r', '').strip()
|
||||||
|
|
||||||
|
# 根据来源确定消息类型和发送者
|
||||||
|
if source == 'HOST':
|
||||||
|
message_type = 'host'
|
||||||
|
sender = 'Forum Host'
|
||||||
|
else:
|
||||||
|
message_type = 'agent'
|
||||||
|
sender = f'{source.title()} Engine'
|
||||||
|
|
||||||
|
return {
|
||||||
|
'type': message_type,
|
||||||
|
'sender': sender,
|
||||||
|
'content': cleaned_content,
|
||||||
|
'timestamp': timestamp,
|
||||||
|
'source': source
|
||||||
|
}
|
||||||
|
|
||||||
# Forum日志监听器
|
# Forum日志监听器
|
||||||
# 存储每个客户端的历史日志发送位置
|
# 存储每个客户端的历史日志发送位置
|
||||||
|
|||||||
Reference in New Issue
Block a user