Skip to content

[log] refactor(difc): consolidate agent.go logging to use internal debug logger#2982

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
log/difc-agent-consistent-logging-262419761c67f00c
Draft

[log] refactor(difc): consolidate agent.go logging to use internal debug logger#2982
github-actions[bot] wants to merge 1 commit intomainfrom
log/difc-agent-consistent-logging-262419761c67f00c

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 1, 2026

Summary

Consolidates debug logging in internal/difc/agent.go to use the project's internal logAgent debug logger consistently, replacing all log.Printf calls from the standard library.

Problem

The file mixed two logging mechanisms:

  • logAgent.Printf (internal logger) — respects DEBUG env var, writes to mcp-gateway.log
  • log.Printf("[DIFC] ...") (standard library) — always writes to stderr, bypasses DEBUG controls

This 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

  • Replaced 10 log.Printf("[DIFC] ...") calls with logAgent.Printf(...) throughout agent.go
  • Removed the now-unused "log" standard library import
  • Dropped the redundant [DIFC] message prefix (the difc:agent namespace already provides that context)

Benefits

  • Debug logs now respect DEBUG=difc:agent (or DEBUG=*) env var — no more noise in production stderr
  • Messages are captured to mcp-gateway.log via the file logger
  • Output includes colored namespace + time diffs in terminals during development
  • Consistent with logging conventions used across the rest of the codebase

Testing

Enable debug logging to verify:

DEBUG=difc:agent ./awmg --config config.toml

Generated by Go Logger Enhancement ·

…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>
@github-actions github-actions bot added automation enhancement New feature or request labels Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants