From e538b3b32b2373cb5461b1a6a447380376821c14 Mon Sep 17 00:00:00 2001 From: Ed Zynda Date: Thu, 16 Oct 2025 16:31:15 +0300 Subject: [PATCH] fix: suppress health check logging to debug output only 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. --- internal/tools/connection_pool.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/internal/tools/connection_pool.go b/internal/tools/connection_pool.go index e98db55..edffa58 100644 --- a/internal/tools/connection_pool.go +++ b/internal/tools/connection_pool.go @@ -155,7 +155,9 @@ func (p *MCPConnectionPool) GetConnectionWithHealthCheck(ctx context.Context, se delete(p.connections, serverName) } } else { - fmt.Printf("🔍 [POOL] Connection %s unhealthy, removing\n", serverName) + if p.debugLogger != nil && p.debugLogger.IsDebugEnabled() { + p.debugLogger.LogDebug(fmt.Sprintf("[POOL] Connection %s unhealthy, removing", serverName)) + } conn.client.Close() delete(p.connections, serverName) } @@ -182,7 +184,9 @@ func (p *MCPConnectionPool) performHealthCheck(ctx context.Context, conn *MCPCon // Try to list tools as a health check - this is a lightweight operation _, err := conn.client.ListTools(healthCtx, mcp.ListToolsRequest{}) if err != nil { - fmt.Printf("⚠️ [HEALTH_CHECK] Connection %s failed health check: %v\n", conn.serverName, err) + if p.debugLogger != nil && p.debugLogger.IsDebugEnabled() { + p.debugLogger.LogDebug(fmt.Sprintf("[HEALTH_CHECK] Connection %s failed health check: %v", conn.serverName, err)) + } conn.mu.Lock() conn.isHealthy = false conn.errorCount++ @@ -410,12 +414,16 @@ func (p *MCPConnectionPool) checkConnectionsHealth() { if time.Since(conn.lastUsed) > p.config.MaxIdleTime { conn.isHealthy = false - fmt.Printf("🔍 [HEALTH_CHECK] Connection %s marked as unhealthy due to inactivity\n", serverName) + if p.debugLogger != nil && p.debugLogger.IsDebugEnabled() { + p.debugLogger.LogDebug(fmt.Sprintf("[HEALTH_CHECK] Connection %s marked as unhealthy due to inactivity", serverName)) + } } if conn.errorCount > p.config.MaxErrorCount { conn.isHealthy = false - fmt.Printf("🔍 [HEALTH_CHECK] Connection %s marked as unhealthy due to errors\n", serverName) + if p.debugLogger != nil && p.debugLogger.IsDebugEnabled() { + p.debugLogger.LogDebug(fmt.Sprintf("[HEALTH_CHECK] Connection %s marked as unhealthy due to errors", serverName)) + } } conn.mu.Unlock()