Skip to content

feat: print logging level on startup and centralize DEBUG constant#611

Merged
lpcox merged 1 commit intomainfrom
lpcox/print-debug-level
Feb 3, 2026
Merged

feat: print logging level on startup and centralize DEBUG constant#611
lpcox merged 1 commit intomainfrom
lpcox/print-debug-level

Conversation

@lpcox
Copy link
Collaborator

@lpcox lpcox commented Feb 3, 2026

  • Print logging verbosity level to stdout on startup
  • Create constants.go with EnvDebug and EnvDebugColors constants
  • Refactor all DEBUG env var references to use logger.EnvDebug
  • Update tests to use the centralized constant

- Print logging verbosity level to stdout on startup
- Create constants.go with EnvDebug and EnvDebugColors constants
- Refactor all DEBUG env var references to use logger.EnvDebug
- Update tests to use the centralized constant
Copilot AI review requested due to automatic review settings February 3, 2026 16:37
@lpcox lpcox merged commit 0241ffe into main Feb 3, 2026
13 checks passed
@lpcox lpcox deleted the lpcox/print-debug-level branch February 3, 2026 16:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR centralizes logging-related environment variable names and surfaces the effective logging verbosity during startup, while wiring this behavior into tests and CI workflows.

Changes:

  • Introduces internal/logger/constants.go with EnvDebug and EnvDebugColors and refactors logger code and tests to use these constants for reading DEBUG and DEBUG_COLORS.
  • Updates preRun in internal/cmd/root.go to derive logging verbosity from the verbosity flag, set the DEBUG env var accordingly when unset, and print a human-readable logging level (or the existing DEBUG value) via the standard logger.
  • Adjusts tests (internal/cmd/root_test.go, internal/logger/slog_adapter_test.go) and the smoke Copilot workflow to align with the centralized DEBUG handling and to propagate DEBUG cleanly into the MCP gateway container.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/logger/constants.go Adds EnvDebug and EnvDebugColors constants with documentation to centralize logging-related env var names.
internal/logger/logger.go Switches color control and DEBUG pattern evaluation to use EnvDebugColors/EnvDebug, keeping logger behavior but centralizing configuration keys.
internal/logger/slog_adapter_test.go Updates slog adapter tests to use EnvDebug instead of the raw "DEBUG" string when deciding whether to run or skip.
internal/cmd/root.go Enhances preRun to read DEBUG via logger.EnvDebug, conditionally set it based on verbosity, and log the resolved logging level or inherited DEBUG setting.
internal/cmd/root_test.go Aligns pre-run validation tests with logger.EnvDebug, ensuring new verbosity-to-DEBUG behavior is covered and respects pre-existing env values.
.github/workflows/smoke-copilot.lock.yml Exports DEBUG="*" explicitly and passes it through to the MCP gateway container via -e DEBUG, simplifying the docker env wiring.
Comments suppressed due to low confidence (1)

internal/cmd/root.go:117

  • Similar to the debug level case above, this branch still hardcodes the "DEBUG" environment variable name instead of using the new logger.EnvDebug constant, even though the PR description calls out centralizing DEBUG env var references. For consistency and easier future refactoring, it would be better to use logger.EnvDebug here as well.
			os.Setenv("DEBUG", debugAllPackages)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

log.Printf("Logging level: info (-v)")
case 2:
// Debug level - enable debug logs for main packages
os.Setenv("DEBUG", debugMainPackages)
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

This switch still hardcodes the "DEBUG" environment variable name when setting verbosity-derived patterns, even though this PR introduces the logger.EnvDebug constant and the description says all DEBUG env var references should be centralized. To keep the environment key definition in one place and avoid future drift, consider using logger.EnvDebug in this os.Setenv call.

Copilot uses AI. Check for mistakes.
Comment on lines +110 to +114
log.Printf("Logging level: info (-v)")
case 2:
// Debug level - enable debug logs for main packages
os.Setenv("DEBUG", debugMainPackages)
debugLog.Printf("Verbosity level: debug (DEBUG=%s)", debugMainPackages)
log.Printf("Logging level: debug (-vv), DEBUG=%s", debugMainPackages)
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The new log.Printf("Logging level: ...") calls use Go's default logger, which writes to stderr by default, but the PR description says the verbosity level should be printed to stdout on startup. If the goal is truly stdout, consider either configuring the standard logger's output to os.Stdout or using a dedicated logger that targets stdout, or otherwise update the description/comments to match the actual behavior.

Copilot uses AI. Check for mistakes.
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