Deduplicate LogMarshaledForDebug callback wiring with formatted helper#7631
Merged
Conversation
Copilot
AI
changed the title
[WIP] Refactor duplicate LogMarshaledForDebug callback structure
Deduplicate Jun 16, 2026
LogMarshaledForDebug callback wiring with formatted helper
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces duplicated debug-logging callback wiring around logger.LogMarshaledForDebug by introducing a formatted helper (LogMarshaledForDebugf) and migrating the existing call sites in guard/server paths to use it, while keeping message templates local to each call site.
Changes:
- Added
logger.LogMarshaledForDebugfto centralize the marshal-success / marshal-failure formatted-callback plumbing. - Updated guard/session initialization and WASM guard logging paths to use the new helper instead of duplicating callbacks.
- Added unit tests covering success and marshal-failure behavior for
LogMarshaledForDebugf.
Show a summary per file
| File | Description |
|---|---|
internal/server/guard_init.go |
Replaces inline marshal success/failure callbacks with LogMarshaledForDebugf for label_agent response logging. |
internal/logger/rpc_helpers.go |
Introduces LogMarshaledForDebugf, built on top of LogMarshaledForDebug, to standardize formatted callback wiring. |
internal/logger/rpc_helpers_test.go |
Adds focused unit tests for the new formatted helper’s success and failure paths. |
internal/guard/wasm.go |
Deduplicates guard policy/response debug logging by switching to LogMarshaledForDebugf with logWasm.Printf. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 1
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
logger.LogMarshaledForDebugwas used with near-identical success/failure callback blocks in three guard/server paths, creating avoidable duplication and drift risk in debug logging behavior. This change centralizes that wiring while preserving per-call-site message text and log level behavior.What changed
logger.LogMarshaledForDebugfininternal/logger/rpc_helpers.goto standardize marshal-success / marshal-failure callback dispatch for formatted log functions.internal/guard/wasm.go(normalized policy log, parsed response log)internal/server/guard_init.go(label_agentresponse log)internal/logger/rpc_helpers_test.go(success and marshal-failure formatting paths).Design intent