Skip to content

Commit a2c5a12

Browse files
Add debug logging to cmd/proxy.go
Adds 5 new logProxyCmd debug log calls to improve troubleshooting of the proxy subcommand: - Log proxy server creation parameters (guard path, policy presence, DIFC mode, trusted bot/user counts) before proxy.New - Log successful proxy server creation - Log HTTP server creation with TLS state - Log when TLS configuration is applied to the HTTP server - Log TLS trust environment setup (CA cert path and env vars being set) - Log successful TLS trust environment configuration These debug logs are controlled by DEBUG=cmd:proxy and write to both stderr (colorized, with time diffs) and the gateway log file. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 18b19a6 commit a2c5a12

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

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)