use crate::documents::active_logs_dir;
use agentic_logging::CallTimer;
use agentic_logging::LogWriter;
use agentic_logging::ToolCallRecord;
pub fn log_tool_call(
timer: &CallTimer,
tool: &str,
request: serde_json::Value,
success: bool,
error: Option<String>,
summary: Option<serde_json::Value>,
) {
let writer = match active_logs_dir() {
Ok(dir) => LogWriter::new(dir),
Err(_) => return, };
let (completed_at, duration_ms) = timer.finish();
let record = ToolCallRecord {
call_id: timer.call_id.clone(),
server: "thoughts_tool".into(),
tool: tool.into(),
started_at: timer.started_at,
completed_at,
duration_ms,
request,
response_file: None,
success,
error,
model: None,
token_usage: None,
summary,
};
if let Err(e) = writer.append_jsonl(&record) {
tracing::warn!("Failed to append JSONL log: {}", e);
}
}