Unit 03.04: Logging a call so you can explain it later
A log line that explains a call, without containing its content.
Versions, usage, outcome
The fields that make a call explainable six weeks later.
The code prints one.
import json
record = {
"request_id": "r-8841",
"prompt_version": "reply-v3",
"model": "some-model-2026-06",
"input_tokens": 96,
"output_tokens": 12,
"finish_reason": "stop",
"latency_ms": 780,
"usd": 0.0000468,
"outcome": "validated ok",
"content": "[redacted]",
}
print(json.dumps(record, indent=2))
print("\nenough to explain a call; not enough to leak its content")
# `prompt_version` and `model` are the two that let you explain a run six weeks
# later, after the prompt has been edited three times. Neither is recoverable
# afterwards.
prompt_version and model are the two that matter most and the two most often omitted. The prompt changes weekly, is rarely thought of as a deploy, and without the version recorded you cannot explain any run made before the last edit.
content is redacted here, which is Module 12's subject - the point is that everything else is enough to diagnose most problems.
The mistake this prevents
The mistake is logging the full prompt and response for debugging. It is genuinely useful and it makes your log store a second copy of both user input and retrieved documents, usually with broader access than either.
Takeaway
Log request id, both versions, usage, latency and outcome. That explains most problems without your logs becoming a copy of the content.
