Toggle navigation
Toggle navigation
This project
Loading...
Sign in
万朱浩
/
Venue-Ops
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
马一丁
2025-11-22 13:31:42 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8fbac74808c74ee5608be4a1b0a8952de1b47fad
8fbac748
1 parent
17657513
Fixed the Issue Where the Host Information was not Displayed
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
10 deletions
app.py
app.py
View file @
8fbac74
...
...
@@ -377,35 +377,43 @@ def parse_forum_log_line(line):
"""解析forum.log行内容,提取对话信息"""
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
)
if
match
:
timestamp
,
source
,
content
=
match
.
groups
()
if
not
match
:
return
None
timestamp
,
raw_source
,
content
=
match
.
groups
()
source
=
raw_source
.
strip
()
.
upper
()
# 过滤掉系统消息和空内容
if
source
==
'SYSTEM'
or
not
content
.
strip
():
return
None
# 只处理三个Engine的消息
if
source
not
in
[
'QUERY'
,
'INSIGHT'
,
'MEDIA'
]:
# 支持三个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} Engine'
sender
=
f
'{source
.title()
} Engine'
return
{
'type'
:
message_type
,
'sender'
:
sender
,
'content'
:
content
.
strip
()
,
'content'
:
cleaned_content
,
'timestamp'
:
timestamp
,
'source'
:
source
}
return
None
# Forum日志监听器
# 存储每个客户端的历史日志发送位置
forum_log_positions
=
{}
...
...
Please
register
or
login
to post a comment