Commit 0d4e760
authored
[log] Add debug logging to container detection in sys/container.go (#2598)
## Summary
Adds a package-level debug logger (`logSys`) and 4 meaningful debug log
calls to `internal/sys/container.go`, following the project's
`pkg:filename` naming convention from AGENTS.md.
## Changes
**File modified:** `internal/sys/container.go`
### What was added
1. Import for `github.com/github/gh-aw-mcpg/internal/logger`
2. Package-level logger variable: `var logSys =
logger.New("sys:container")`
3. Debug log at function entry: `"Detecting container environment"`
4. Detection method trace logs for each of the 3 detection paths:
- `"Container detected via /.dockerenv"` (Method 1)
- `"Container detected via /proc/1/cgroup"` (Method 2)
- `"Container detected via RUNNING_IN_CONTAINER env var"` (Method 3)
5. Fallback log: `"No container indicators found, running on host"`
## Why this is useful
`IsRunningInContainer()` is a critical detection function used to
determine execution context and control security behavior (e.g., whether
direct command execution is permitted). When troubleshooting container
detection issues, developers had no visibility into which detection
method triggered (or why detection failed). With this change, running
`DEBUG=sys:* ./awmg --config config.toml` reveals exactly which method
fires.
## Quality checklist
- [x] Exactly 1 file modified
- [x] No test files modified
- [x] Logger declaration added following `pkg:filename` convention
(`sys:container`)
- [x] Log arguments are all string literals (no side effects)
- [x] Messages are meaningful and actionable for debugging
- [x] No duplicate logging with existing logs
- [x] Import statements properly formatted
- [x] Naming follows project convention (`logSys` matches `logConn`,
`logSchema`, etc.)
> Generated by [Go Logger
Enhancement](https://github.com/github/gh-aw-mcpg/actions/runs/23612565368)
·
[◷](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: 23612565368, workflow_id: go-logger, run:
https://github.com/github/gh-aw-mcpg/actions/runs/23612565368 -->
<!-- gh-aw-workflow-id: go-logger -->1 file changed
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
| 10 | + | |
| 11 | + | |
8 | 12 | | |
9 | 13 | | |
| 14 | + | |
| 15 | + | |
10 | 16 | | |
11 | 17 | | |
| 18 | + | |
12 | 19 | | |
13 | 20 | | |
14 | 21 | | |
| |||
20 | 27 | | |
21 | 28 | | |
22 | 29 | | |
| 30 | + | |
23 | 31 | | |
24 | 32 | | |
25 | 33 | | |
26 | 34 | | |
27 | 35 | | |
28 | 36 | | |
| 37 | + | |
29 | 38 | | |
30 | 39 | | |
31 | 40 | | |
| 41 | + | |
32 | 42 | | |
33 | 43 | | |
0 commit comments