Skip to content

[log] Replace stdlib log calls with logRouted debug logger in routed.go#6959

Merged
lpcox merged 1 commit into
mainfrom
log/routed-debug-logging-3ad3b0b27b2b9e74
Jun 4, 2026
Merged

[log] Replace stdlib log calls with logRouted debug logger in routed.go#6959
lpcox merged 1 commit into
mainfrom
log/routed-debug-logging-3ad3b0b27b2b9e74

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented Jun 4, 2026

Summary

internal/server/routed.go contained four log.Printf calls using the standard library log package alongside the project's own logRouted debug logger. This PR converts all four to use logRouted.Printf, making the file consistent with the rest of the codebase.

Changes

  • Removed the "log" standard-library import from routed.go
  • Converted four log.Printf calls to logRouted.Printf:
    1. Route registration: "Registered route: %s"
    2. Filtered server creation count: "Creating filtered server for %s with %d tools"
    3. Missing handler warning: "WARNING: No handler found for %s___%s"
    4. Per-call trace in the routed handler closure: "[ROUTED] Calling unified handler for: %s"

Why This Matters

Standard library log writes unconditionally to stderr; it cannot be filtered, coloured, or directed to the file logger. By using logRouted, these messages now:

  • Are gated behind the DEBUG=server:* (or DEBUG=*) environment variable — zero overhead when disabled
  • Write to both stderr (with colours and time-diffs) and mcp-gateway.log for post-hoc analysis
  • Follow the pkg:filename namespace convention already used throughout the project

Validation

  • go build ./... — no errors
  • go vet ./internal/server/... — clean
  • go test ./internal/server/... — all tests pass

Generated by Go Logger Enhancement · sonnet46 4.9M ·

Convert four log.Printf calls (standard library) to use the project's
logRouted debug logger, consistent with the rest of the codebase. This
ensures routed-mode debug output is controlled via the DEBUG env var,
writes to both stderr (with colours) and the file logger, and follows
the pkg:filename naming convention.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added automation enhancement New feature or request labels Jun 4, 2026
@lpcox lpcox marked this pull request as ready for review June 4, 2026 14:38
Copilot AI review requested due to automatic review settings June 4, 2026 14:38
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 standardizes logging in internal/server/routed.go by removing remaining standard-library log.Printf usage and routing those messages through the project’s logRouted debug logger, aligning the file with the repository’s debug-logger pattern.

Changes:

  • Removed the log (stdlib) import from internal/server/routed.go.
  • Replaced four log.Printf calls with logRouted.Printf for route registration, filtered server creation, missing handler warnings, and routed call tracing.
Show a summary per file
File Description
internal/server/routed.go Removes stdlib logging and routes debug output through logRouted for consistency and debug gating.

Copilot's findings

Tip

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

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@lpcox lpcox merged commit fc5221d into main Jun 4, 2026
23 checks passed
@lpcox lpcox deleted the log/routed-debug-logging-3ad3b0b27b2b9e74 branch June 4, 2026 15:45
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