Skip to content

Pass the caller's logger to default transports in New and cluster.StartWith - #33

Merged
thrawn01 merged 1 commit into
mainfrom
thrawn01/eng-580-default-transports-ignore-the-callers-logger
Oct 29, 2026
Merged

thrawn01 merged 1 commit into
mainfrom
thrawn01/eng-580-default-transports-ignore-the-callers-logger

Conversation

@thrawn01

Copy link
Copy Markdown
Contributor

Purpose

Follow-up to #28. A caller who passes Options.Logger without a Transport expects the transport's "Listening on…" and server-error messages in that logger. Two paths still sent them to slog.Default():

  • groupcache.New() built its default transport with empty options.
  • cluster.StartWith built the parent transport with empty options. Daemon 1 got the Use provided logger in daemon constructor #28 default, but daemons 2..N come from parent.New(), which copies the parent's empty options.
cluster.Start(ctx, 3, groupcache.Options{Logger: logger})
// before: only daemon 1 logged to `logger`
// after:  all 3 daemons log "Listening on ..." to `logger`

With no logger the behavior is unchanged (slog.Default()). cmd/server/main.go is untouched, as it already uses slog.Default().

Implementation

  • instance.go: default transport gets Logger: opts.Logger.
  • cluster/cluster.go: parent transport gets Logger: opts.Logger.
  • cluster/cluster_test.go: TestStartLogsEveryDaemonToLogger starts 3 daemons with a capturing logger and expects 3 "Listening on" lines. It failed before the fix (never reached 3) and passes after.

Verified with go vet ./... and go test -p 1 -race ./... (all pass). Without -p 1, packages collide on the fixed test ports, which predates this change.

Not verified: the New() change has no test. The default transport is not reachable from Instance, so no surface test can observe its logger. It is the same one-line change as daemon.go. No sub-agent review was run, only my own read of the diff.

Fixes ENG-580

@thrawn01
thrawn01 merged commit dda0e04 into main Oct 29, 2026
1 check passed
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.

1 participant