You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
chore: migrate log.Printf to log/slog in agent and cmd - #533
Follow-up to #488 (traffic/, egress/, enrich/, evidence/) and disjoint from #523 (llmpool/, llmrec/, intercept/, db/). All remaining non-test log.Printf/log.Print/log.Println calls in agent/ and cmd/ still used unstructured formatting instead of log/slog, so the logs view had to guess severity from message text instead of reading the slog level word directly.
Changes
Replaced all 26 log.Print/log.Printf call sites across 11 files in agent/ (assembly.go, compaction.go, coverage.go, noa.go, provider.go, spill.go, toolrag.go, tools.go, tools_insert.go, triage.go, worker.go) and all 13 non-fatal log.Printf/log.Println call sites across cmd/artex/main.go and cmd/artex-archive-check/main.go with log/slog (slog.Info, slog.Warn, slog.Error).
Preserved every existing [tag] prefix ([agent], [compaction], [config], [coverage], [insert_assets], [llm-test], [noa], [tool-rag], [tools], [triage]) so server/logsink.goparseLog keeps the tag badges and reads the exact slog level word directly.
Kept the three process-terminating log.Fatal/log.Fatalf calls in cmd/ unchanged.
Flattened the [llm-test] connection-attempt log (agent/provider.go) into structured single-line attributes (response_body via clipBody) and structured [noa] diagnostics as a quoted msg attribute.
Added agent/slog_test.go verifying [tag] and slog level preservation through log.Default().
Testing
gofmt -l agent/ cmd/ — clean
Verified 0 remaining log.Print* calls in non-test agent/ and cmd/ files
go build ./... — passed
go vet ./... — passed
go test -race -p 1 ./agent ./cmd/... — passed (agent, cmd/artex; Postgres-dependent tests skipped without ARTEX_PG_DSN)
Almost ready. No secrets are newly logged and log.Fatalf("serve…") and the return 1 paths in cmd/artex/main.go are kept. It touches different files from #536 and #523, and its agent/provider.go hunk applies cleanly alongside #538.
Required:[config] snapshot {json} becomes snapshot config="{\"…\"}", escaped on one line. docs/OPS.md:25 documents the old form, and grep/parse tooling relying on it breaks. Either update the doc or keep the raw JSON in the message.
Nits: the panic stack trace in agent/assembly.go also becomes a single escaped line. The new agent/slog_test.go swaps the global log output, so stray goroutines logging during the test could make it flaky.
[config] snapshot (cmd/artex/main.go): kept raw unescaped JSON in the message (slog.Info("[config] snapshot " + string(b))) so it stays compatible with docs/OPS.md:25 and existing grep/parse tooling.
Panic stack trace (agent/assembly.go): kept the formatted multi-line stack trace in the slog.Error message instead of an escaped single-line attribute.
agent/slog_test.go: switched to a mutex-guarded slog.Handler via slog.SetDefault matching on the specific [noa] and [llm-test] records, avoiding global log.SetOutput mutation and stray-goroutine flakiness.
Merged, thanks @brixtonpham. Verified on current main with its tests and negative control.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem / Context
Follow-up to #488 (
traffic/,egress/,enrich/,evidence/) and disjoint from #523 (llmpool/,llmrec/,intercept/,db/). All remaining non-testlog.Printf/log.Print/log.Printlncalls inagent/andcmd/still used unstructured formatting instead oflog/slog, so the logs view had to guess severity from message text instead of reading thesloglevel word directly.Changes
log.Print/log.Printfcall sites across 11 files inagent/(assembly.go,compaction.go,coverage.go,noa.go,provider.go,spill.go,toolrag.go,tools.go,tools_insert.go,triage.go,worker.go) and all 13 non-fatallog.Printf/log.Printlncall sites acrosscmd/artex/main.goandcmd/artex-archive-check/main.gowithlog/slog(slog.Info,slog.Warn,slog.Error).[tag]prefix ([agent],[compaction],[config],[coverage],[insert_assets],[llm-test],[noa],[tool-rag],[tools],[triage]) soserver/logsink.goparseLogkeeps the tag badges and reads the exactsloglevel word directly.log.Fatal/log.Fatalfcalls incmd/unchanged.[llm-test]connection-attempt log (agent/provider.go) into structured single-line attributes (response_bodyviaclipBody) and structured[noa]diagnostics as a quotedmsgattribute.agent/slog_test.goverifying[tag]andsloglevel preservation throughlog.Default().Testing
gofmt -l agent/ cmd/— cleanlog.Print*calls in non-testagent/andcmd/filesgo build ./...— passedgo vet ./...— passedgo test -race -p 1 ./agent ./cmd/...— passed (agent,cmd/artex; Postgres-dependent tests skipped withoutARTEX_PG_DSN)go test -p 1 ./server -run TestParseLog— passed