Skip to content

Commit 267904a

Browse files
authored
[log] Add debug logging to cmd/proxy (#4134)
Adds 5 new `logProxyCmd` debug log calls to `internal/cmd/proxy.go` to improve troubleshooting of the `awmg proxy` subcommand. ## Changes **`internal/cmd/proxy.go`** — reuses the existing `logProxyCmd = logger.New("cmd:proxy")` logger: - Log proxy server creation parameters before `proxy.New` (guard path, policy presence, DIFC mode, trusted bot/user counts) - Log successful proxy server creation - Log HTTP server creation with TLS state - Log when TLS configuration is applied to the HTTP server - Log entry to `configureTLSTrustEnvironment` (CA cert path + env var names) - Log successful TLS trust environment configuration ## Usage Enable with `DEBUG=cmd:proxy ./awmg proxy ...` or `DEBUG=* ./awmg proxy ...`. ## Validation - `go build` passes (GOTOOLCHAIN=auto go1.25.0) - `go vet ./internal/cmd/...` passes - `gofmt` clean - All unit tests pass (pre-existing `TestFetchAndFixSchema_NetworkError` failure is unrelated to this change and reproducible on `main` without my changes) > [!WARNING] > <details> > <summary><strong>⚠️ Firewall blocked 1 domain</strong></summary> > > The following domain was blocked by the firewall during workflow execution: > > - `invalidhostthatdoesnotexist12345.com` > > To allow these domains, add them to the `network.allowed` list in your workflow frontmatter: > > ```yaml > network: > allowed: > - defaults > - "invalidhostthatdoesnotexist12345.com" > ``` > > See [Network Configuration](https://github.github.com/gh-aw/reference/network/) for more information. > > </details> > Generated by [Go Logger Enhancement](https://github.com/github/gh-aw-mcpg/actions/runs/24621566931/agentic_workflow) · ● 5.8M · [◷](https://github.com/search?q=repo%3Agithub%2Fgh-aw-mcpg+%22gh-aw-workflow-id%3A+go-logger%22&type=pullrequests) <!-- gh-aw-agentic-workflow: Go Logger Enhancement, engine: copilot, model: auto, id: 24621566931, workflow_id: go-logger, run: https://github.com/github/gh-aw-mcpg/actions/runs/24621566931 --> <!-- gh-aw-workflow-id: go-logger -->
2 parents 0ae43b4 + a2c5a12 commit 267904a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

internal/cmd/proxy.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ func runProxy(cmd *cobra.Command, args []string) error {
203203
logProxyCmd.Printf("Resolved GitHub API URL: %s, explicit flag=%v", apiURL, proxyAPIURL != "")
204204

205205
// Create the proxy server
206+
logProxyCmd.Printf("Creating proxy server: guard=%s, hasPolicy=%v, mode=%s, trustedBots=%d, trustedUsers=%d",
207+
proxyGuardWasm, proxyPolicy != "", proxyDIFCMode, len(proxyTrustedBots), len(proxyTrustedUsers))
206208
proxySrv, err := proxy.New(ctx, proxy.Config{
207209
WasmPath: proxyGuardWasm,
208210
Policy: proxyPolicy,
@@ -215,6 +217,7 @@ func runProxy(cmd *cobra.Command, args []string) error {
215217
if err != nil {
216218
return fmt.Errorf("failed to create proxy server: %w", err)
217219
}
220+
logProxyCmd.Printf("Proxy server created successfully")
218221

219222
// Generate TLS certificates if requested
220223
var tlsCfg *proxy.TLSConfig
@@ -235,11 +238,13 @@ func runProxy(cmd *cobra.Command, args []string) error {
235238
}
236239

237240
// Create the HTTP server
241+
logProxyCmd.Printf("Creating HTTP server: addr=%s, tls=%v", proxyListen, tlsCfg != nil)
238242
httpServer := &http.Server{
239243
Addr: proxyListen,
240244
Handler: proxySrv.Handler(),
241245
}
242246
if tlsCfg != nil {
247+
logProxyCmd.Printf("Applying TLS configuration to HTTP server")
243248
httpServer.TLSConfig = tlsCfg.Config
244249
}
245250

@@ -318,10 +323,12 @@ func configureTLSTrustEnvironment(caCertPath string) error {
318323
return fmt.Errorf("invalid TLS CA cert path contains newline")
319324
}
320325

326+
logProxyCmd.Printf("Configuring TLS trust environment: caCertPath=%s, envVars=%v", caCertPath, tlsTrustEnvKeys)
321327
for _, key := range tlsTrustEnvKeys {
322328
if err := os.Setenv(key, caCertPath); err != nil {
323329
return fmt.Errorf("failed to set %s: %w", key, err)
324330
}
325331
}
332+
logProxyCmd.Printf("TLS trust environment configured successfully: %d env vars set", len(tlsTrustEnvKeys))
326333
return nil
327334
}

0 commit comments

Comments
 (0)