Skip to content

Commit 1c83b02

Browse files
authored
[log] log: add debug logging to server/difc_log (#2228)
Adds a `logDifcLog` debug logger (`"server:difc_log"` namespace) to `internal/server/difc_log.go` and instruments the three key functions with 5 meaningful debug logging calls. ## Changes **File:** `internal/server/difc_log.go` - Added `var logDifcLog = logger.New("server:difc_log")` (reuses the existing `logger` import) - `logFilteredItems`: logs filtered item count at entry (`serverID`, `toolName`, `count`) - `buildFilteredItemLogEntry`: logs extracted DIFC labels (`description`, `secrecy`, `integrity`) and item metadata (`author`, `number`, `URL`) when available - `buildDIFCFilteredNotice`: logs filtered item count and which notice format branch is selected (per-item detail vs. summary-only) ## Why this file `difc_log.go` contains the DIFC filtering pipeline's logging and notice-building logic. Understanding *how many* items are being filtered, *what labels* they carry, and *which code path* the notice builder takes is critical when debugging integrity policy violations. The existing operational logging (via `logger.LogInfoWithServer`) records the outcome; these debug logs trace the control flow that produces it. ## Usage ```bash # Enable debug logs for this file only DEBUG=server:difc_log ./awmg --config config.toml # Enable all server debug logs DEBUG=server:* ./awmg --config config.toml ``` All log calls are zero-overhead when `DEBUG` does not match the namespace. > Generated by [Go Logger Enhancement](https://github.com/github/gh-aw-mcpg/actions/runs/23350545859) · [◷](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, id: 23350545859, workflow_id: go-logger, run: https://github.com/github/gh-aw-mcpg/actions/runs/23350545859 --> <!-- gh-aw-workflow-id: go-logger -->
2 parents a1038fd + 636c7c5 commit 1c83b02

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

internal/server/difc_log.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ import (
99
"github.com/github/gh-aw-mcpg/internal/logger"
1010
)
1111

12+
var logDifcLog = logger.New("server:difc_log")
13+
1214
// logFilteredItems logs structured details for every item removed by DIFC filtering.
1315
// Each item is written as a [DIFC-FILTERED] JSON entry to both the unified and
1416
// per-server text log files (via LogInfoWithServer), and as a DIFC_FILTERED entry
1517
// in the JSONL log.
1618
func logFilteredItems(serverID, toolName string, filtered *difc.FilteredCollectionLabeledData) {
19+
logDifcLog.Printf("Logging filtered items: serverID=%s, toolName=%s, count=%d", serverID, toolName, len(filtered.Filtered))
1720
for _, detail := range filtered.Filtered {
1821
entry := buildFilteredItemLogEntry(serverID, toolName, detail)
1922
b, err := json.Marshal(entry)
@@ -39,6 +42,7 @@ func buildFilteredItemLogEntry(serverID, toolName string, detail difc.FilteredIt
3942
entry.Description = detail.Item.Labels.Description
4043
entry.SecrecyTags = difc.TagsToStrings(detail.Item.Labels.Secrecy.Label.GetTags())
4144
entry.IntegrityTags = difc.TagsToStrings(detail.Item.Labels.Integrity.Label.GetTags())
45+
logDifcLog.Printf("Filtered item labels: description=%s, secrecy=%v, integrity=%v", entry.Description, entry.SecrecyTags, entry.IntegrityTags)
4246
}
4347

4448
// Extract identifying metadata from the raw item data.
@@ -49,6 +53,7 @@ func buildFilteredItemLogEntry(serverID, toolName string, detail difc.FilteredIt
4953
entry.HTMLURL = getStringField(m, "html_url", "htmlUrl")
5054
entry.Number = extractNumberField(m)
5155
entry.SHA = getStringField(m, "sha")
56+
logDifcLog.Printf("Filtered item metadata: author=%s, number=%s, url=%s", entry.AuthorLogin, entry.Number, entry.HTMLURL)
5257
}
5358

5459
return entry
@@ -117,8 +122,11 @@ func buildDIFCFilteredNotice(filtered *difc.FilteredCollectionLabeledData) strin
117122
return ""
118123
}
119124

125+
logDifcLog.Printf("Building DIFC filtered notice: filteredCount=%d, maxInline=%d", n, maxFilteredItemsInNotice)
126+
120127
// For a small number of filtered items, include per-item descriptions and reasons.
121128
if n <= maxFilteredItemsInNotice {
129+
logDifcLog.Printf("Using per-item notice format for %d item(s)", n)
122130
parts := make([]string, 0, n)
123131
for _, detail := range filtered.Filtered {
124132
desc := ""

0 commit comments

Comments
 (0)