[log] refactor(difc): consolidate agent.go logging to use internal debug logger#2982
Draft
github-actions[bot] wants to merge 1 commit intomainfrom
Draft
[log] refactor(difc): consolidate agent.go logging to use internal debug logger#2982github-actions[bot] wants to merge 1 commit intomainfrom
github-actions[bot] wants to merge 1 commit intomainfrom
Conversation
…gger Replace all standard library log.Printf calls in internal/difc/agent.go with logAgent.Printf from the project's internal debug logger. Previously the file mixed two logging mechanisms: - logAgent.Printf (internal logger) for some calls - log.Printf (standard library) for others with [DIFC] prefix The standard library calls always wrote to stderr regardless of the DEBUG env var, bypassing the project's debug logging controls. Converting them to logAgent.Printf means: - Logs only appear when DEBUG=difc:agent (or DEBUG=*) - Messages are captured to mcp-gateway.log via the file logger - Output includes colored namespace + time diffs in terminals The [DIFC] prefix in the old messages is now redundant since the logger namespace difc:agent provides the same context. Also removes the now-unused "log" standard library import. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
4 tasks
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.
Summary
Consolidates debug logging in
internal/difc/agent.goto use the project's internallogAgentdebug logger consistently, replacing alllog.Printfcalls from the standard library.Problem
The file mixed two logging mechanisms:
logAgent.Printf(internal logger) — respectsDEBUGenv var, writes tomcp-gateway.loglog.Printf("[DIFC] ...")(standard library) — always writes to stderr, bypassesDEBUGcontrolsThis meant DIFC agent state changes (label modifications, propagation events, registry operations) were always printed to stderr in production, even when debug logging was disabled.
Changes
log.Printf("[DIFC] ...")calls withlogAgent.Printf(...)throughoutagent.go"log"standard library import[DIFC]message prefix (thedifc:agentnamespace already provides that context)Benefits
DEBUG=difc:agent(orDEBUG=*) env var — no more noise in production stderrmcp-gateway.logvia the file loggerTesting
Enable debug logging to verify: