Skip to content

Commit d56335e

Browse files
authored
fix: suppress health check logging to debug output only (#135)
Replace fmt.Printf calls in connection pool health check routines with debug logger calls. Health check messages are now only displayed when the --debug flag is enabled, providing a cleaner terminal output during normal operation while maintaining diagnostic information for troubleshooting.
1 parent 13acf44 commit d56335e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

internal/tools/connection_pool.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ func (p *MCPConnectionPool) GetConnectionWithHealthCheck(ctx context.Context, se
155155
delete(p.connections, serverName)
156156
}
157157
} else {
158-
fmt.Printf("🔍 [POOL] Connection %s unhealthy, removing\n", serverName)
158+
if p.debugLogger != nil && p.debugLogger.IsDebugEnabled() {
159+
p.debugLogger.LogDebug(fmt.Sprintf("[POOL] Connection %s unhealthy, removing", serverName))
160+
}
159161
conn.client.Close()
160162
delete(p.connections, serverName)
161163
}
@@ -182,7 +184,9 @@ func (p *MCPConnectionPool) performHealthCheck(ctx context.Context, conn *MCPCon
182184
// Try to list tools as a health check - this is a lightweight operation
183185
_, err := conn.client.ListTools(healthCtx, mcp.ListToolsRequest{})
184186
if err != nil {
185-
fmt.Printf("⚠️ [HEALTH_CHECK] Connection %s failed health check: %v\n", conn.serverName, err)
187+
if p.debugLogger != nil && p.debugLogger.IsDebugEnabled() {
188+
p.debugLogger.LogDebug(fmt.Sprintf("[HEALTH_CHECK] Connection %s failed health check: %v", conn.serverName, err))
189+
}
186190
conn.mu.Lock()
187191
conn.isHealthy = false
188192
conn.errorCount++
@@ -410,12 +414,16 @@ func (p *MCPConnectionPool) checkConnectionsHealth() {
410414

411415
if time.Since(conn.lastUsed) > p.config.MaxIdleTime {
412416
conn.isHealthy = false
413-
fmt.Printf("🔍 [HEALTH_CHECK] Connection %s marked as unhealthy due to inactivity\n", serverName)
417+
if p.debugLogger != nil && p.debugLogger.IsDebugEnabled() {
418+
p.debugLogger.LogDebug(fmt.Sprintf("[HEALTH_CHECK] Connection %s marked as unhealthy due to inactivity", serverName))
419+
}
414420
}
415421

416422
if conn.errorCount > p.config.MaxErrorCount {
417423
conn.isHealthy = false
418-
fmt.Printf("🔍 [HEALTH_CHECK] Connection %s marked as unhealthy due to errors\n", serverName)
424+
if p.debugLogger != nil && p.debugLogger.IsDebugEnabled() {
425+
p.debugLogger.LogDebug(fmt.Sprintf("[HEALTH_CHECK] Connection %s marked as unhealthy due to errors", serverName))
426+
}
419427
}
420428

421429
conn.mu.Unlock()

0 commit comments

Comments
 (0)