feat: add opt-in JSONL format for trace logs (Closes #8066)#8109
Open
Pleiades1726 wants to merge 3 commits into
Open
feat: add opt-in JSONL format for trace logs (Closes #8066)#8109Pleiades1726 wants to merge 3 commits into
Pleiades1726 wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- When
trace_log_formathas an unexpected value,_add_file_sinksilently falls back to the prefixed format; consider validating against the allowed options and either raising or logging a warning so misconfigurations are visible. - You now have the literal strings "prefixed" and "jsonl" in both the config schema and
log.py; consider centralizing these as constants or an enum-like structure to avoid divergence if new formats are added later.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- When `trace_log_format` has an unexpected value, `_add_file_sink` silently falls back to the prefixed format; consider validating against the allowed options and either raising or logging a warning so misconfigurations are visible.
- You now have the literal strings "prefixed" and "jsonl" in both the config schema and `log.py`; consider centralizing these as constants or an enum-like structure to avoid divergence if new formats are added later.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a new configuration option trace_log_format for trace logging, allowing users to choose between a timestamp-prefixed format and a raw jsonl format. The changes include updates to the default configuration, schema validation, and the logging utility to handle the format selection. I have no feedback to provide.
added 2 commits
May 9, 2026 22:02
Add a new config option 'trace_log_format' that supports two modes: - 'prefixed' (default): [time] prefix format, backward compatible - 'jsonl': pure JSON Lines format without prefix, each line is a valid JSON object parseable by jq, Python json.loads, ELK, etc. This allows downstream tools and dashboards to ingest trace log files directly without needing to regex-strip the timestamp prefix. Closes AstrBotDevs#8066
fe7138c to
714cc34
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
详见 Issue #8066。当前 trace 日志格式为带
[time]前缀的格式,导致每行不是合法的 JSON,下游工具(jq、Pythonjson.loads、ELK 等)无法直接解析。改动
新增配置项
trace_log_format,支持两种模式:prefixed(默认)[2026-05-07 13:45:12.123] {...}jsonl{...}修改文件
astrbot/core/config/default.py— 添加默认值 + metadata schema(两处)astrbot/core/log.py—_add_file_sink()新增trace_format参数,configure_trace_logger()读取配置并传递使用方式
在
data/config.yaml中设置:重启后 trace 日志将输出纯 JSON Lines 格式。
Summary by Sourcery
Add a configurable format for trace log output, allowing opt-in JSON Lines in addition to the existing prefixed format.
New Features:
Enhancements: