Commit b9c4059
authored
[log] Add debug logging to GenerateRandomAPIKey in auth/apikey.go (#4002)
## Summary
Adds 3 debug logging calls to `internal/auth/apikey.go` using the
existing package-level logger (`log`, declared in `auth/header.go`).
### Changes
**`internal/auth/apikey.go`** — 3 new `log.Print` / `log.Printf` calls
in `GenerateRandomAPIKey`:
| Location | Log message |
|----------|-------------|
| Function entry | `"Generating random API key"` |
| On error | `"Random API key generation failed: %v"` |
| On success | `"Random API key generated successfully"` |
### Why this file?
`GenerateRandomAPIKey` is called at gateway startup (spec §7.3) whenever
no API key is configured. Logging this lifecycle event helps developers:
- Confirm that key generation occurs when expected
- Diagnose failures in `strutil.RandomHex` (e.g., entropy issues)
- See the startup sequence in `DEBUG=auth:*` output
### Design decisions
- **Reuses existing logger**: `var log = logger.New("auth:header")` is
already declared in the `auth` package. No new logger variable or import
is needed in `apikey.go`.
- **No key exposure**: The log messages confirm generation
success/failure without logging the actual key value.
- **No side effects**: All log arguments are already-evaluated
variables.
### Validation
- `go build ./...` ✅
- `go vet ./...` ✅
- `go test ./internal/auth/...` ✅ (all tests pass)
- `go test ./...` ✅ (all unit tests pass; pre-existing integration test
failures unrelated to this change)
### Enabling debug output
```bash
DEBUG=auth:* ./awmg --config config.toml
```
> [!WARNING]
> <details>
> <summary><strong>1 file changed
+6
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| 10 | + | |
| 11 | + | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
| 16 | + | |
13 | 17 | | |
14 | 18 | | |
| 19 | + | |
15 | 20 | | |
16 | 21 | | |
| 22 | + | |
17 | 23 | | |
18 | 24 | | |
0 commit comments