Skip to content

[log] Add debug logger to cmd/proxy.go#2752

Merged
lpcox merged 1 commit intomainfrom
log/add-debug-logging-cmd-proxy-6fafe1fd95361fcd
Mar 29, 2026
Merged

[log] Add debug logger to cmd/proxy.go#2752
lpcox merged 1 commit intomainfrom
log/add-debug-logging-cmd-proxy-6fafe1fd95361fcd

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Adds a logProxyCmd = logger.New("cmd:proxy") debug logger to internal/cmd/proxy.go and 6 meaningful debug log calls.

Changes

File: internal/cmd/proxy.go

  • Added var logProxyCmd = logger.New("cmd:proxy") — follows the pkg:filename convention and the logXxx naming pattern used across the codebase
  • No new import needed — logger was already imported

Logging calls added

Location Log message Purpose
detectGuardWasm() "Checking for baked-in guard at %s" Visible before stat call
detectGuardWasm() "Auto-detected baked-in guard: %s" Confirms container image guard path
detectGuardWasm() "Baked-in guard not found, --guard-wasm flag required" Explains why flag is required
runProxy() "Starting proxy: listen=%s, guard=%s, mode=%s, tls=%v" Entry point summary
runProxy() "Resolved GitHub API URL: %s, explicit flag=%v" Shows resolved URL and whether it came from flag
runProxy() "Generating TLS certificates in: %s" Before potentially slow cert generation

Why this file?

cmd/proxy.go imports logger and uses logger.LogInfo (file logger) throughout but had no debug logger (logger.New()). The existing file-logger calls go to proxy.log always; the new debug calls only emit output when DEBUG=cmd:* or DEBUG=* is set, providing zero-overhead diagnostics for developers.

Testing

Enable with:

DEBUG=cmd:* ./awmg proxy --guard-wasm ... --listen 0.0.0.0:8443

Generated by Go Logger Enhancement ·

Add logProxyCmd = logger.New("cmd:proxy") debug logger to the proxy
subcommand and add 6 meaningful debug log calls:

- detectGuardWasm: log the baked-in guard path check, detection result
- runProxy: log proxy startup parameters, resolved GitHub API URL,
  and TLS certificate directory when TLS is enabled

This makes the proxy startup flow observable under DEBUG=cmd:* without
duplicating existing logger.LogInfo (file logger) calls.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lpcox lpcox marked this pull request as ready for review March 29, 2026 15:10
Copilot AI review requested due to automatic review settings March 29, 2026 15:10
@lpcox lpcox merged commit 0d1555e into main Mar 29, 2026
3 checks passed
@lpcox lpcox deleted the log/add-debug-logging-cmd-proxy-6fafe1fd95361fcd branch March 29, 2026 15:10
Copy link
Copy Markdown
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

Adds a package-scoped debug logger for the proxy CLI subcommand and emits additional debug-level diagnostics to aid local troubleshooting without impacting normal log output.

Changes:

  • Introduces logProxyCmd = logger.New("cmd:proxy") in internal/cmd/proxy.go.
  • Adds debug log lines around baked-in guard detection, proxy startup configuration, GitHub API URL resolution, and TLS certificate generation.

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

Comment thread internal/cmd/proxy.go
Comment on lines 47 to +51
if _, err := os.Stat(containerGuardWasmPath); err == nil {
logProxyCmd.Printf("Auto-detected baked-in guard: %s", containerGuardWasmPath)
return containerGuardWasmPath
}
logProxyCmd.Print("Baked-in guard not found, --guard-wasm flag required")
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

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

The message "Baked-in guard not found" is logged for any os.Stat error. If the file exists but Stat fails (e.g., permission/IO error), this is misleading and hides the real cause. Consider branching on os.IsNotExist(err) for the 'not found' message, and otherwise log the error (or include it in the debug output) before returning.

Suggested change
if _, err := os.Stat(containerGuardWasmPath); err == nil {
logProxyCmd.Printf("Auto-detected baked-in guard: %s", containerGuardWasmPath)
return containerGuardWasmPath
}
logProxyCmd.Print("Baked-in guard not found, --guard-wasm flag required")
_, err := os.Stat(containerGuardWasmPath)
if err == nil {
logProxyCmd.Printf("Auto-detected baked-in guard: %s", containerGuardWasmPath)
return containerGuardWasmPath
}
if os.IsNotExist(err) {
logProxyCmd.Print("Baked-in guard not found, --guard-wasm flag required")
} else {
logProxyCmd.Printf("Error checking for baked-in guard at %s: %v", containerGuardWasmPath, err)
}

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.

2 participants