Documentation
¶
Overview ¶
Package logging provides optional per-run logging for all model adapter calls.
Usage:
logger, err := logging.NewLogger("data/runs.jsonl")
if err != nil { ... }
defer logger.Close()
adapters = logging.WrapAll(adapters, sessionID, logger)
Pass a nil *Logger to WrapAll to disable logging with no overhead.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Wrap ¶
func Wrap(adapter models.ModelAdapter, sessionID string, l *Logger) models.ModelAdapter
Wrap returns a ModelAdapter that logs every RunAgent call to l. If l is nil the original adapter is returned unchanged (zero overhead).
func WrapAll ¶
func WrapAll(adapters []models.ModelAdapter, sessionID string, l *Logger) []models.ModelAdapter
WrapAll wraps a slice of adapters. Convenience helper for wrapping all at once.
Types ¶
type Entry ¶
type Entry struct {
TS time.Time `json:"ts"`
SessionID string `json:"session_id"`
RunID string `json:"run_id"`
ModelID string `json:"model_id"`
Prompt string `json:"prompt"`
Events []EventRecord `json:"events"`
Response ResponseRecord `json:"response"`
}
Entry is one complete agent-run record. One entry is appended to the JSONL log file each time a model adapter finishes a RunAgent call.
type EventRecord ¶
type EventRecord struct {
Type models.EventType `json:"type"` // "reading" | "writing" | "text" | "error" | "bash" | "snapshot"
Data string `json:"data"`
}
EventRecord captures a single tool event emitted during the run.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger writes run entries to an append-only JSONL file. All methods are safe for concurrent use.
type ResponseRecord ¶
type ResponseRecord struct {
Text string `json:"text"`
InputTokens int64 `json:"input_tokens"`
OutputTokens int64 `json:"output_tokens"`
ReasoningTokens int64 `json:"reasoning_tokens,omitempty"`
CostUSD float64 `json:"cost_usd"`
LatencyMS int64 `json:"latency_ms"`
ProposedFiles []string `json:"proposed_files"`
Writes []WriteRecord `json:"writes,omitempty"`
ToolCalls map[string]int `json:"tool_calls,omitempty"`
Error string `json:"error,omitempty"`
}
ResponseRecord captures the final outcome of a RunAgent call.
type WriteRecord ¶
WriteRecord captures one proposed file write (path + full content).