Remove redundant logging calls in routed.go #458
Merged
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.
Debug loggers created with
logger.New()automatically write to both stderr and the file logger. The routed server was duplicating these writes with explicitlog.Printf()calls.Changes
Removed 3 redundant
log.Printf()calls ininternal/server/routed.go:Added
[CACHE]prefix to debug logger calls to preserve categorization.Example
Before:
After:
The debug logger's
Printf()method (logger.go:120) already callsLogDebug()to write to the file logger, making the second call redundant.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
nonexistent.local/tmp/go-build3904863373/b269/launcher.test /tmp/go-build3904863373/b269/launcher.test -test.testlogfile=/tmp/go-build3904863373/b269/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true go ternal/fips140cache/cache.go 64/pkg/tool/linux_amd64/compile(dns block)this-host-does-not-exist-12345.com/tmp/go-build3904863373/b278/mcp.test /tmp/go-build3904863373/b278/mcp.test -test.testlogfile=/tmp/go-build3904863373/b278/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true go1.25.6 -c=4 -nolocalimports -importcfg /tmp/go-build2239539067/b188/importcfg -pack /opt/hostedtoolcache/go/1.25.6/x64/src/net/http/httptrace/trace.go conf�� g_.a go x_amd64/vet user.name(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
This section details on the original issue you should resolve
<issue_title>[duplicate-code] Duplicate Code Pattern: Dual Logging Calls in Server</issue_title>
<issue_description># 🔍 Duplicate Code Pattern: Dual Logging Calls in Server
Part of duplicate code analysis: #435
Summary
The
routed.gofile contains numerous instances where the same log message is written to both the debug logger (logRouted.Printf) and the file logger (log.Printf). This pattern appears 19+ times in routed.go alone, creating visual noise and maintenance burden.Duplication Details
Pattern: Dual Logging Statements
internal/server/routed.go(lines 40-41, 52-53, 58-59, 110-113, and many more)Code Examples:
Example 1: Cache operations (lines 40-41)
Example 2: Server creation (lines 58-59)
Example 3: Request logging (lines 110-113)
Note: Some log statements also appear in
unified.gowhere bothlogUnified.Printf()andlog.Printf()are used.Pattern Analysis:
The dual logging appears to serve two purposes:
logRouted.Printf/logUnified.Printf): Controlled byDEBUGenvironment variable, outputs to stderr with colors and timestampslog.Printf): Writes to operational log file for production troubleshootingHowever, according to the logger package documentation, debug loggers created with
logger.New()already write to both stderr AND the file logger, making the dual calls redundant.Impact Analysis
Maintainability
Bug Risk
[CACHE]prefix appearing only in file logger calls)Code Bloat
Performance
Refactoring Recommendations
Option 1: Use Debug Logger Only (Recommended)
According to
internal/logger/logger.godocumentation:Solution: Remove all
log.Printf()calls and use only the debug logger:Benefits:
Verification needed: Confirm that debug loggers do write to file logger as documented
Estimated effort: 1-2 hours
Option 2: Create Unified Logging Helper
If debug loggers don't write to file logger as expected, create a helper:
Usage:
Benefits:
Drawbacks:
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.