Part of duplicate code analysis: #3207
Summary
The same event is logged twice in rapid succession — once through the structured logger.LogXxxWithServer() helper (writes to structured file log) and once through Go's stdlib log.Printf("[LAUNCHER]...") (writes to stdout). This pattern recurs at least 5 times in internal/launcher/launcher.go.
Duplication Details
Pattern: Redundant dual-sink logging at each significant launcher event
// Lines 117–119: HTTP backend configured
logger.LogInfoWithServer(serverID, "backend", "Configuring HTTP MCP backend: %s, url=%s", serverID, serverCfg.URL)
log.Printf("[LAUNCHER] Configuring HTTP MCP backend: %s", serverID)
log.Printf("[LAUNCHER] URL: %s", serverCfg.URL)
// Lines 144–146: HTTP connection failed
logger.LogErrorWithServer(serverID, "backend", "Failed to create HTTP connection: %s, error=%v", serverID, err)
log.Printf("[LAUNCHER] ❌ FAILED to create HTTP connection for '%s'", serverID)
log.Printf("[LAUNCHER] Error: %v", err)
// Lines 151–152: HTTP backend success
logger.LogInfoWithServer(serverID, "backend", "Successfully configured HTTP MCP backend: %s", serverID)
log.Printf("[LAUNCHER] Successfully configured HTTP backend: %s", serverID)
Impact Analysis
- Maintainability: Each message must be kept in sync across both sinks; a format or content change requires two edits.
- Bug Risk: The two log lines can drift — e.g.
serverCfg.URL is included in the structured log but not in the log.Printf equivalent at lines 118–119.
- Code Bloat: ~15 extra lines of
log.Printf calls that duplicate information already captured by the structured logger.
- Consistency: The pattern is not uniform; some events only use one sink, making log coverage unpredictable.
Refactoring Recommendations
- Remove redundant
log.Printf calls where logger.LogXxxWithServer already covers the same information. The structured file logger (plus logLauncher.Printf for debug details) is sufficient.
- Add stdout forwarding to the file logger if stdout visibility is required — this can be done once centrally in the logger initialisation rather than at every call site.
- Estimated effort: 30–60 minutes to remove the ~10 redundant
log.Printf lines from launcher.go.
Implementation Checklist
Parent Issue
See parent analysis report: #3207
Related to #3207
Generated by Duplicate Code Detector · ◷
Part of duplicate code analysis: #3207
Summary
The same event is logged twice in rapid succession — once through the structured
logger.LogXxxWithServer()helper (writes to structured file log) and once through Go's stdliblog.Printf("[LAUNCHER]...")(writes to stdout). This pattern recurs at least 5 times ininternal/launcher/launcher.go.Duplication Details
Pattern: Redundant dual-sink logging at each significant launcher event
Severity: High
Occurrences: 5+ paired call sites in
internal/launcher/launcher.goLocations:
internal/launcher/launcher.golines 117–119internal/launcher/launcher.golines 144–146internal/launcher/launcher.golines 151–152Code Sample:
Impact Analysis
serverCfg.URLis included in the structured log but not in thelog.Printfequivalent at lines 118–119.log.Printfcalls that duplicate information already captured by the structured logger.Refactoring Recommendations
log.Printfcalls wherelogger.LogXxxWithServeralready covers the same information. The structured file logger (pluslogLauncher.Printffor debug details) is sufficient.log.Printflines fromlauncher.go.Implementation Checklist
log.Printf("[LAUNCHER]...")calls inlauncher.goandlog_helpers.gologger.LogXxxWithServercalllog.Printfcalls (e.g. for OIDC warning at line 78–79) are intentionalmake testto confirm no behaviour changeParent Issue
See parent analysis report: #3207
Related to #3207