Skip to content

chore: migrate log.Printf to log/slog in traffic, egress, enrich and evidence - #488

Merged
BaaRai merged 3 commits into
BaaRai:mainfrom
sresarehumantoo:chore/slog-migration-v2
Nov 23, 2026
Merged

BaaRai merged 3 commits into
BaaRai:mainfrom
sresarehumantoo:chore/slog-migration-v2

Conversation

@sresarehumantoo

Copy link
Copy Markdown
Contributor

Summary

  • Replace all log.Printf / log.Print calls with structured log/slog equivalents in traffic/, egress/, enrich/ and evidence/.
  • Swap the "log" import for "log/slog" in every affected file. No log.Fatal or log.Panic calls existed in these packages, so the "log" import is fully removed.
  • Update three test assertions in traffic/rewrite_flow_test.go that 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 ./... passes
  • go test ./traffic/... ./egress/... ./enrich/... ./evidence/... passes
  • Verified no log.Printf / log.Print calls remain in the four packages (excluding test files that use log.SetOutput for capture)

@BaaRai

BaaRai commented Nov 22, 2026

Copy link
Copy Markdown
Owner

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.
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 BaaRai left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@BaaRai
BaaRai merged commit a37403d into BaaRai:main Nov 23, 2026
6 checks passed
@BaaRai

BaaRai commented Nov 23, 2026

Copy link
Copy Markdown
Owner

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.

BaaRai pushed a commit that referenced this pull request Nov 26, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants