Repository navigation
chore: migrate log.Printf to log/slog in traffic, egress, enrich and evidence - #488
Conversation
|
This branch conflicts with main and touches logging across 13 files. Please rebase on current main; I will review the redaction and message levels once it is mergeable. No review until then. |
…vidence/ Replace every log.Printf/log.Print call with structured slog equivalents and swap the "log" import for "log/slog". Update test assertions that matched the old format strings.
0a7d56b to
10afb2e
Compare
The slog migration dropped the [traffic], [egress], [enrich] and [evidence] tags, so the logs view lost the badge and the level was guessed from the message text. Put the tag back in each message and teach parseLog to read the slog level word (2026/11/23 13:48:50 WARN [traffic] ...) before the tag. Adds parseLog tests for the real slog line, the level words and the legacy no-level shape.
BaaRai
left a comment
There was a problem hiding this comment.
Thanks for the slog migration.
It dropped the tags at the call sites, so the logs view lost the badge and parseLog guessed the level from the message text: a real line such as 2026/11/23 13:48:50 WARN [traffic] MITM failed, falling back to passthrough host=example.com ttl=1m0s err=boom showed an empty tag and the error level.
I pushed 3112fef on your branch: each original call carries its tag again (54 tagged lines, none doubled), and parseLog reads the slog level word before the tag, while lines without a level word keep the old keyword guess and leading-tag rule. The commit adds tests on the real slog line, the level words and the legacy shape. Your commits are unchanged.
Merging once CI is green.
|
Merged. Thanks @sresarehumantoo for the slog migration: the traffic, egress, enrich and evidence call sites keep their tags now, and the logs view reads the level from the slog line instead of guessing it from the message. |
…nd db Follow-up to #488. Replaces the remaining 18 log.Printf calls in these four packages with structured slog calls, keeping the [tag] prefix that the log sink uses. Format arguments become key/value attributes.
Summary
log.Printf/log.Printcalls with structuredlog/slogequivalents intraffic/,egress/,enrich/andevidence/."log"import for"log/slog"in every affected file. Nolog.Fatalorlog.Paniccalls existed in these packages, so the"log"import is fully removed.traffic/rewrite_flow_test.gothat matched the old format-string output to match the new slog key=value format.This covers 13 files and roughly 50 call sites. The messages preserve the same information (host, error, rule IDs, etc.) as structured key-value pairs instead of interpolated strings.
Test plan
go build ./...passesgo test ./traffic/... ./egress/... ./enrich/... ./evidence/...passeslog.Printf/log.Printcalls remain in the four packages (excluding test files that uselog.SetOutputfor capture)