thoughts_tool/utils/
logging.rs1use crate::documents::active_logs_dir;
7use agentic_logging::CallTimer;
8use agentic_logging::LogWriter;
9use agentic_logging::ToolCallRecord;
10
11pub fn log_tool_call(
16 timer: &CallTimer,
17 tool: &str,
18 request: serde_json::Value,
19 success: bool,
20 error: Option<String>,
21 summary: Option<serde_json::Value>,
22) {
23 let writer = match active_logs_dir() {
24 Ok(dir) => LogWriter::new(dir),
25 Err(_) => return, };
27
28 let (completed_at, duration_ms) = timer.finish();
29 let record = ToolCallRecord {
30 call_id: timer.call_id.clone(),
31 server: "thoughts_tool".into(),
32 tool: tool.into(),
33 started_at: timer.started_at,
34 completed_at,
35 duration_ms,
36 request,
37 response_file: None,
38 success,
39 error,
40 model: None,
41 token_usage: None,
42 summary,
43 };
44
45 if let Err(e) = writer.append_jsonl(&record) {
46 tracing::warn!("Failed to append JSONL log: {}", e);
47 }
48}