Conversation
Replace the legacy standard-library logger (log.New discarding by default, toggled via SetDebug) with the project's debug logger pattern (logger.New). This makes config package debug output consistent with the rest of the codebase: - Controlled via DEBUG env var (e.g. DEBUG=config:* or DEBUG=*) - Writes to stderr with colors/time-diffs in TTY mode - Also written to the file logger for production troubleshooting Remove the now-unnecessary SetDebug function; callers can use the standard DEBUG env var to enable config debug output. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Migrates the config package’s debug logging in internal/config/config_core.go from a legacy log.New(io.Discard, ...) approach to the repo’s standard internal/logger debug logger, so config debug output can be controlled via DEBUG patterns.
Changes:
- Remove legacy
logConfiginitialization andSetDebugtoggling. - Introduce
logConfigas alogger.New(...)instance controlled byDEBUG.
Show a summary per file
| File | Description |
|---|---|
| internal/config/config_core.go | Replaces legacy stdlib logger + SetDebug with project debug logger instance. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
| // logConfig is the debug logger for the config package. | ||
| // Enable with DEBUG=config:* or DEBUG=*. | ||
| var logConfig = logger.New("config:config") |
There was a problem hiding this comment.
logConfig is initialized at package init via logger.New(...), which computes the enabled state once at construction time. Since the CLI sets DEBUG at runtime in internal/cmd/root.go (for -vv/-vvv), this logger will stay disabled even after DEBUG is set, so these config debug logs still won’t appear when users enable verbosity flags. Consider constructing the logger lazily after DEBUG is finalized (e.g., create it inside the load functions or behind a sync.Once getter), or adjust the logger implementation to re-evaluate DEBUG on each call.
Summary
Migrates
internal/config/config_core.gofrom the legacylog.Newpattern to the project's standard debug logger (logger.New).Changes
File modified:
internal/config/config_core.goBefore
After
Motivation
The config package was the last package in
internal/still using the legacylog.New(io.Discard, ...)pattern. This pattern required explicitSetDebug(true)calls (which were never made anywhere in the codebase) to see any output.The project's
logger.Newpattern:DEBUGenv var (e.g.DEBUG=config:*orDEBUG=*)mcp-gateway.log) for production troubleshootingImpact
logConfig.Printf(...)calls in bothconfig_core.goandconfig_stdin.gonow route through the project's debug loggerSetDebugis removed (was never called; no callers exist)ioandlogstandard library imports removed fromconfig_core.goDEBUGenv var matches)Testing
go build ./...(no compilation errors)go test ./...(no regressions)go vet ./...(no issues)