Commit 51d0a40
authored
[log] Add debug logging to DIFC agent module (#751)
## Summary
Enhanced `internal/difc/agent.go` with debug logging using the internal
logger package, following project conventions from AGENTS.md.
## Changes
**Added internal logger infrastructure:**
- Imported `github.com/github/gh-aw-mcpg/internal/logger`
- Added `var logAgent = logger.New("difc:agent")` following the
`pkg:filename` naming convention
**Added debug logging to 5 key functions:**
1. **`NewAgentLabels()`** - Logs agent creation with agentID
2. **`NewAgentLabelsWithTags()`** - Logs agent creation with initial
secrecy/integrity tags
3. **`AddSecrecyTag()`** - Logs before acquiring lock for secrecy tag
addition
4. **`AddIntegrityTag()`** - Logs before acquiring lock for integrity
tag addition
5. **`GetOrCreate()`** - Logs agent lookup/creation flow including:
- Entry point with agentID
- Cache hits (existing agent found)
- Race condition detection (agent created by another goroutine)
## Design Principles
- **No side effects** - All log arguments are simple variable references
- **Strategic placement** - Logs at function entry and key control flow
decisions
- **Complementary** - New debug logs complement (not replace) existing
operational logs
- **Convention compliance** - Follows `pkg:filename` naming pattern and
logger best practices
- **Thread safety** - Logs placed before lock acquisition to avoid
deadlocks
## Testing
Due to environment constraints, the changes require CI validation:
``````bash
make build && make test && go vet ./...
``````
The code changes are syntactically correct and follow all project
conventions. CI will verify:
- ✅ Code compiles without errors
- ✅ All tests pass
- ✅ No lint/vet issues
## Debugging Usage
Enable DIFC agent debug logging:
``````bash
# Enable all DIFC logging
DEBUG=difc:* ./awmg --config config.toml
# Enable specific agent logging
DEBUG=difc:agent ./awmg --config config.toml
``````
## Files Changed
- `internal/difc/agent.go` - 1 file, +13 lines (7 debug logging calls)
## Related
This PR is part of the ongoing effort to enhance debug logging across
the codebase for better troubleshooting and development visibility.
> AI generated by [Go Logger
Enhancement](https://github.com/github/gh-aw-mcpg/actions/runs/21756493008)
<!-- gh-aw-workflow-id: go-logger -->1 file changed
Lines changed: 13 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 | | |
10 | 14 | | |
| |||
16 | 20 | | |
17 | 21 | | |
18 | 22 | | |
| 23 | + | |
19 | 24 | | |
20 | 25 | | |
21 | 26 | | |
| |||
25 | 30 | | |
26 | 31 | | |
27 | 32 | | |
| 33 | + | |
| 34 | + | |
28 | 35 | | |
29 | 36 | | |
30 | 37 | | |
| |||
34 | 41 | | |
35 | 42 | | |
36 | 43 | | |
| 44 | + | |
37 | 45 | | |
38 | 46 | | |
39 | 47 | | |
| |||
42 | 50 | | |
43 | 51 | | |
44 | 52 | | |
| 53 | + | |
45 | 54 | | |
46 | 55 | | |
47 | 56 | | |
| |||
132 | 141 | | |
133 | 142 | | |
134 | 143 | | |
| 144 | + | |
| 145 | + | |
135 | 146 | | |
136 | 147 | | |
137 | 148 | | |
138 | 149 | | |
| 150 | + | |
139 | 151 | | |
140 | 152 | | |
141 | 153 | | |
| |||
146 | 158 | | |
147 | 159 | | |
148 | 160 | | |
| 161 | + | |
149 | 162 | | |
150 | 163 | | |
151 | 164 | | |
| |||
0 commit comments