Debug
NAME
LLM::Chat::Debug - Optional wire-level debug log for chat backends
DESCRIPTION
Append-only file logger for raw HTTP traffic on chat backends. Gated
on the LLM_CHAT_DEBUG environment variable: when set, treated as a
filesystem path and every request / response chunk is appended there.
When unset, every log call is a no-op so the production cost is a
hash lookup per call.
The logger serialises concurrent writes through an internal lock ā it's safe to call from multiple in-flight backends at once.
The Authorization header is redacted automatically when a header
hash is logged via log-headers; everything else is written verbatim,
so prompts, model names, generation ids, and provider-specific extras
are all visible. Keep the log out of source control.
SYNOPSIS
# Enable for the lifetime of a process:
# LLM_CHAT_DEBUG=/tmp/llm-chat.log raku script.raku
# tail -f /tmp/llm-chat.log
use LLM::Chat::Debug;
LLM::Chat::Debug.log('REQUEST URL', $url);
LLM::Chat::Debug.log-headers('REQUEST HEADERS', %headers);
LLM::Chat::Debug.log-json('REQUEST BODY', %body);
# In a streaming loop:
LLM::Chat::Debug.log('SSE LINE', $raw-line);
LLM::Chat::Debug.log('RESPONSE END', "done");