Skip to content

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

Merged
lpcox merged 1 commit intomainfrom
log/difc-agent-consistent-logging-262419761c67f00c
Apr 3, 2026
Merged

[log] refactor(difc): consolidate agent.go logging to use internal debug logger#2982
lpcox merged 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
@lpcox lpcox marked this pull request as ready for review April 3, 2026 04:53
Copilot AI review requested due to automatic review settings April 3, 2026 04:53
@lpcox lpcox merged commit 7f73bda into main Apr 3, 2026
3 checks passed
@lpcox lpcox deleted the log/difc-agent-consistent-logging-262419761c67f00c branch April 3, 2026 04:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR consolidates debug logging in internal/difc/agent.go by replacing standard library log.Printf calls with the project’s internal logAgent logger so DIFC agent debug output respects DEBUG filtering and routes to the configured log sink.

Changes:

  • Replaced remaining log.Printf("[DIFC] ...") statements with logAgent.Printf(...).
  • Removed the now-unused log stdlib import.
  • Dropped the redundant [DIFC] prefix since the logger namespace (difc:agent) already scopes the messages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants