mirror of
https://github.com/openai/codex.git
synced 2026-05-03 12:52:11 +03:00
fix(app-server) emit logs as json-rpc
This commit is contained in:
@@ -874,6 +874,7 @@ pub struct FuzzyFileSearchSessionCompletedNotification {
|
||||
server_notification_definitions! {
|
||||
/// NEW NOTIFICATIONS
|
||||
Error => "error" (v2::ErrorNotification),
|
||||
LogEntry => "log/entry" (v2::LogEntryNotification),
|
||||
ThreadStarted => "thread/started" (v2::ThreadStartedNotification),
|
||||
ThreadStatusChanged => "thread/status/changed" (v2::ThreadStatusChangedNotification),
|
||||
ThreadArchived => "thread/archived" (v2::ThreadArchivedNotification),
|
||||
@@ -1576,6 +1577,50 @@ mod tests {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_log_entry_notification() -> Result<()> {
|
||||
let notification = ServerNotification::LogEntry(v2::LogEntryNotification {
|
||||
timestamp: 1_742_710_400,
|
||||
level: v2::LogEntryLevel::Warn,
|
||||
target: "codex_app_server".to_string(),
|
||||
message: "listener queue is full".to_string(),
|
||||
fields: std::collections::BTreeMap::from([
|
||||
("connectionId".to_string(), serde_json::json!(7)),
|
||||
("retryable".to_string(), serde_json::json!(true)),
|
||||
]),
|
||||
span: Some(v2::LogSpanContext {
|
||||
name: "app_server.request".to_string(),
|
||||
fields: std::collections::BTreeMap::from([(
|
||||
"rpc.method".to_string(),
|
||||
serde_json::json!("thread/start"),
|
||||
)]),
|
||||
}),
|
||||
});
|
||||
assert_eq!(
|
||||
json!({
|
||||
"method": "log/entry",
|
||||
"params": {
|
||||
"timestamp": 1742710400,
|
||||
"level": "warn",
|
||||
"target": "codex_app_server",
|
||||
"message": "listener queue is full",
|
||||
"fields": {
|
||||
"connectionId": 7,
|
||||
"retryable": true,
|
||||
},
|
||||
"span": {
|
||||
"name": "app_server.request",
|
||||
"fields": {
|
||||
"rpc.method": "thread/start",
|
||||
}
|
||||
}
|
||||
}
|
||||
}),
|
||||
serde_json::to_value(¬ification)?,
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_thread_realtime_output_audio_delta_notification() -> Result<()> {
|
||||
let notification = ServerNotification::ThreadRealtimeOutputAudioDelta(
|
||||
|
||||
Reference in New Issue
Block a user