Conversation
pkg/logger's init()-configured global logrus logger, plus package functions taking a hand-written function-name string at every call site, is replaced with a plain logger.New() *slog.Logger constructor. The returned *slog.Logger is threaded explicitly through every function that logs (GetCloudflareAccessTokenForApp, StartMultipleProxies, newDirector, ProxyService/ProxyCFAccess, cmd.Run/initConfig), created once in cmd.Run's RunE. LOG_LEVEL and LOG_FORMAT keep controlling level and format exactly as before, including the fallback to info with a warning on an invalid LOG_LEVEL. The one visible behavior change is that the unused trace level goes away (nothing in production code called logger.Trace, and slog has no built-in trace level). Drops the github.com/sirupsen/logrus dependency entirely.
logrus's manual "function" field, hand-typed at each call site, went away in the slog migration with nothing replacing it. slog's built-in AddSource option gives the same "where did this happen" signal automatically from the runtime call stack — always accurate, never hand-typed or left stale after a rename.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
logger.X(funcName, fmt, args...)package functions) withlog/slog: a plainlogger.New() *slog.Loggerconstructor, threaded explicitly through every function that logs instead of a package-level global.LOG_LEVEL/LOG_FORMATenv vars keep controlling level and format exactly as before, including the fallback toinfowith a warning on an invalidLOG_LEVEL.github.com/sirupsen/logrusentirely.Behavior change
tracelog level goes away (nothing in production code called it, andsloghas no built-in trace level).LOG_LEVEL=tracenow falls back toinfowith a warning like any other invalid value.Test plan
go build ./.../go vet ./...go test -race ./...LOG_LEVEL=debugrun → readable text logs on stderrLOG_FORMAT=json LOG_LEVEL=debugrun → one JSON object per linego list -m all | grep sirupsen→ no output