jsonl-logs-feedback

This commit is contained in:
Ahmed Ibrahim
2025-12-04 16:53:49 -08:00
parent 073a8533b8
commit 66f6fae194
6 changed files with 23 additions and 4 deletions

13
codex-rs/Cargo.lock generated
View File

@@ -6804,6 +6804,16 @@ dependencies = [
"tracing-core",
]
[[package]]
name = "tracing-serde"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "704b1aeb7be0d0a84fc9828cae51dab5970fee5088f83d1dd7ee6f6246fc6ff1"
dependencies = [
"serde",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.3.20"
@@ -6814,12 +6824,15 @@ dependencies = [
"nu-ansi-term",
"once_cell",
"regex-automata",
"serde",
"serde_json",
"sharded-slab",
"smallvec",
"thread_local",
"tracing",
"tracing-core",
"tracing-log",
"tracing-serde",
]
[[package]]

View File

@@ -42,7 +42,7 @@ tokio = { workspace = true, features = [
"signal",
] }
tracing = { workspace = true, features = ["log"] }
tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] }
tracing-subscriber = { workspace = true, features = ["env-filter", "fmt", "json"] }
opentelemetry-appender-tracing = { workspace = true }
uuid = { workspace = true, features = ["serde", "v7"] }

View File

@@ -106,6 +106,9 @@ pub async fn run_main(
.with_filter(EnvFilter::from_default_env());
let feedback_layer = tracing_subscriber::fmt::layer()
.json()
.flatten_event(true)
.with_current_span(false)
.with_writer(feedback.make_writer())
.with_ansi(false)
.with_target(false)

View File

@@ -162,7 +162,7 @@ impl CodexLogSnapshot {
pub fn save_to_temp_file(&self) -> io::Result<PathBuf> {
let dir = std::env::temp_dir();
let filename = format!("codex-feedback-{}.log", self.thread_id);
let filename = format!("codex-feedback-{}.jsonl", self.thread_id);
let path = dir.join(filename);
fs::write(&path, self.as_bytes())?;
Ok(path)
@@ -245,7 +245,7 @@ impl CodexLogSnapshot {
if include_logs {
envelope.add_item(EnvelopeItem::Attachment(Attachment {
buffer: self.bytes.clone(),
filename: String::from("codex-logs.log"),
filename: String::from("codex-logs.jsonl"),
content_type: Some("text/plain".to_string()),
ty: None,
}));

View File

@@ -85,7 +85,7 @@ tokio-stream = { workspace = true }
toml = { workspace = true }
tracing = { workspace = true, features = ["log"] }
tracing-appender = { workspace = true }
tracing-subscriber = { workspace = true, features = ["env-filter"] }
tracing-subscriber = { workspace = true, features = ["env-filter", "json"] }
tree-sitter-bash = { workspace = true }
tree-sitter-highlight = { workspace = true }
unicode-segmentation = { workspace = true }

View File

@@ -277,6 +277,9 @@ pub async fn run_main(
let targets = Targets::new().with_default(tracing::Level::TRACE);
let feedback_layer = tracing_subscriber::fmt::layer()
.json()
.flatten_event(true)
.with_current_span(false)
.with_writer(feedback.make_writer())
.with_ansi(false)
.with_target(false)