mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
ebbbc52ce4
## Summary - store a pre-rendered `feedback_log_body` in SQLite so `/feedback` exports keep span prefixes and structured event fields - render SQLite feedback exports with timestamps and level prefixes to match the old in-memory feedback formatter, while preserving existing trailing newlines - count `feedback_log_body` in the SQLite retention budget so structured or span-prefixed rows still prune correctly - bound `/feedback` row loading in SQL with the retention estimate, then apply exact whole-line truncation in Rust so uploads stay capped without splitting lines ## Details - add a `feedback_log_body` column to `logs` and backfill it from `message` for existing rows - capture span names plus formatted span and event fields at write time, since SQLite does not retain enough structure to reconstruct the old formatter later - keep SQLite feedback queries scoped to the requested thread plus same-process threadless rows - restore a SQL-side cumulative `estimated_bytes` cap for feedback export queries so over-retained partitions do not load every matching row before truncation - add focused formatting coverage for exported feedback lines and parity coverage against `tracing_subscriber` ## Testing - cargo test -p codex-state - just fix -p codex-state - just fmt codex author: `codex resume 019ca1b0-0ecc-78b1-85eb-6befdd7e4f1f` --------- Co-authored-by: Codex <noreply@openai.com>
47 lines
1.1 KiB
Rust
47 lines
1.1 KiB
Rust
use serde::Serialize;
|
|
use sqlx::FromRow;
|
|
|
|
#[derive(Clone, Debug, Serialize)]
|
|
pub struct LogEntry {
|
|
pub ts: i64,
|
|
pub ts_nanos: i64,
|
|
pub level: String,
|
|
pub target: String,
|
|
pub message: Option<String>,
|
|
pub feedback_log_body: Option<String>,
|
|
pub thread_id: Option<String>,
|
|
pub process_uuid: Option<String>,
|
|
pub module_path: Option<String>,
|
|
pub file: Option<String>,
|
|
pub line: Option<i64>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, FromRow)]
|
|
pub struct LogRow {
|
|
pub id: i64,
|
|
pub ts: i64,
|
|
pub ts_nanos: i64,
|
|
pub level: String,
|
|
pub target: String,
|
|
pub message: Option<String>,
|
|
pub thread_id: Option<String>,
|
|
pub process_uuid: Option<String>,
|
|
pub file: Option<String>,
|
|
pub line: Option<i64>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Default)]
|
|
pub struct LogQuery {
|
|
pub level_upper: Option<String>,
|
|
pub from_ts: Option<i64>,
|
|
pub to_ts: Option<i64>,
|
|
pub module_like: Vec<String>,
|
|
pub file_like: Vec<String>,
|
|
pub thread_ids: Vec<String>,
|
|
pub search: Option<String>,
|
|
pub include_threadless: bool,
|
|
pub after_id: Option<i64>,
|
|
pub limit: Option<usize>,
|
|
pub descending: bool,
|
|
}
|