Commit 45c5044
authored
[log] Add debug logging to writeGatewayConfig in cmd/root.go (#1533)
## Summary
Adds 5 meaningful `debugLog.Printf` calls to the `writeGatewayConfig`
function in `internal/cmd/root.go` to improve observability when
troubleshooting gateway configuration output issues.
## Changes
The `writeGatewayConfig` function previously had **zero** debug logging
calls despite being the key function that builds and writes the
gateway's output configuration (per MCP Gateway Spec §5.4). When clients
receive unexpected config output, there was no way to trace what the
function was computing.
**Added logging at:**
1. **Function entry** — logs `listenAddr`, `mode`, and total server
count
2. **After address parsing** — logs resolved `host` and `port` (helps
debug IPv6/IPv4 detection)
3. **Auth config** — logs whether an API key is configured (without
exposing the key)
4. **Per-server URL** — logs server name, computed URL, and tool count
5. **Successful completion** — logs final server count after encoding
## Quality Checklist
- [x] Exactly 1 file modified
- [x] No test files modified
- [x] Reuses existing `debugLog` logger (already declared as `var
debugLog = logger.New("cmd:root")`)
- [x] Logger naming follows `pkg:filename` convention (`cmd:root`)
- [x] Logger arguments don't compute anything or cause side effects
(`len()` is a builtin, no function calls)
- [x] Logging messages are meaningful and helpful for debugging
- [x] No duplication with existing logs
## Example Debug Output
```
DEBUG=cmd:root ./awmg --config config.toml
cmd:root Writing gateway config: listenAddr=127.0.0.1:3000, mode=routed, serverCount=2
cmd:root Parsed listen address: host=127.0.0.1, port=3000
cmd:root Gateway config: auth_enabled=true
cmd:root Writing server config: name=github, url=(127.0.0.1/redacted) toolCount=0
cmd:root Writing server config: name=slack, url=(127.0.0.1/redacted) toolCount=0
cmd:root Gateway config written successfully: serverCount=2
```
> Generated by [Go Logger
Enhancement](https://github.com/github/gh-aw-mcpg/actions/runs/22546627400)
<!-- gh-aw-agentic-workflow: Go Logger Enhancement, engine: copilot, id:
22546627400, workflow_id: go-logger, run:
https://github.com/github/gh-aw-mcpg/actions/runs/22546627400 -->
<!-- gh-aw-workflow-id: go-logger -->1 file changed
+10
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
341 | 341 | | |
342 | 342 | | |
343 | 343 | | |
| 344 | + | |
| 345 | + | |
344 | 346 | | |
345 | 347 | | |
346 | 348 | | |
| |||
352 | 354 | | |
353 | 355 | | |
354 | 356 | | |
| 357 | + | |
355 | 358 | | |
356 | 359 | | |
357 | 360 | | |
| |||
361 | 364 | | |
362 | 365 | | |
363 | 366 | | |
| 367 | + | |
364 | 368 | | |
365 | 369 | | |
366 | 370 | | |
| |||
374 | 378 | | |
375 | 379 | | |
376 | 380 | | |
| 381 | + | |
377 | 382 | | |
378 | | - | |
| 383 | + | |
379 | 384 | | |
380 | 385 | | |
381 | | - | |
| 386 | + | |
382 | 387 | | |
| 388 | + | |
| 389 | + | |
383 | 390 | | |
384 | 391 | | |
385 | 392 | | |
| |||
404 | 411 | | |
405 | 412 | | |
406 | 413 | | |
| 414 | + | |
407 | 415 | | |
408 | 416 | | |
409 | 417 | | |
| |||
0 commit comments