remove info level logging message and use debug instead (#132)

This commit is contained in:
Sébastien Stormacq 2025-08-10 14:40:56 +02:00 • committed by GitHub
commit 9ad382d397
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 23 additions and 23 deletions

View file

@ -152,7 +152,7 @@ public actor HTTPClientTransport: Transport {
streamingTask = Task { await startListeningForServerEvents() } streamingTask = Task { await startListeningForServerEvents() }
} }
logger.info("HTTP transport connected") logger.debug("HTTP transport connected")
} }
/// Disconnects from the transport /// Disconnects from the transport
@ -180,7 +180,7 @@ public actor HTTPClientTransport: Transport {
initialSessionIDContinuation?.resume() initialSessionIDContinuation?.resume()
initialSessionIDContinuation = nil initialSessionIDContinuation = nil
logger.info("HTTP clienttransport disconnected") logger.debug("HTTP clienttransport disconnected")
} }
/// Sends data through an HTTP POST request /// Sends data through an HTTP POST request
@ -440,7 +440,7 @@ public actor HTTPClientTransport: Transport {
"Initial sessionID already available. Proceeding with SSE streaming task immediately." "Initial sessionID already available. Proceeding with SSE streaming task immediately."
) )
} else { } else {
logger.info( logger.trace(
"Proceeding with SSE connection attempt; sessionID is nil. This might be expected for stateless servers or if initialize hasn't provided one yet." "Proceeding with SSE connection attempt; sessionID is nil. This might be expected for stateless servers or if initialize hasn't provided one yet."
) )
} }

View file

@ -368,7 +368,7 @@ import Logging
// Reset reconnect attempt counter on successful connection // Reset reconnect attempt counter on successful connection
reconnectAttempt = 0 reconnectAttempt = 0
logger.info("Network transport connected successfully") logger.debug("Network transport connected successfully")
continuation.resume() continuation.resume()
// Start the receive loop after connection is established // Start the receive loop after connection is established
@ -498,7 +498,7 @@ import Logging
{ {
// Try to reconnect with exponential backoff // Try to reconnect with exponential backoff
reconnectAttempt += 1 reconnectAttempt += 1
logger.info( logger.debug(
"Attempting reconnection after \(context) (\(reconnectAttempt)/\(reconnectionConfig.maxAttempts))..." "Attempting reconnection after \(context) (\(reconnectAttempt)/\(reconnectionConfig.maxAttempts))..."
) )
@ -541,7 +541,7 @@ import Logging
connection.cancel() connection.cancel()
messageContinuation.finish() messageContinuation.finish()
logger.info("Network transport disconnected") logger.debug("Network transport disconnected")
} }
/// Sends data through the network connection /// Sends data through the network connection
@ -658,7 +658,7 @@ import Logging
// Check connection state // Check connection state
if connection.state != .ready { if connection.state != .ready {
logger.info("Connection no longer ready, exiting receive loop") logger.warning("Connection no longer ready, exiting receive loop")
break break
} }
} }
@ -708,7 +708,7 @@ import Logging
&& reconnectAttempt < reconnectionConfig.maxAttempts && reconnectAttempt < reconnectionConfig.maxAttempts
{ {
reconnectAttempt += 1 reconnectAttempt += 1
logger.info( logger.warning(
"Network connection lost, attempting reconnection (\(reconnectAttempt)/\(reconnectionConfig.maxAttempts))..." "Network connection lost, attempting reconnection (\(reconnectAttempt)/\(reconnectionConfig.maxAttempts))..."
) )
@ -759,7 +759,7 @@ import Logging
{ {
// Similar reconnection logic for other errors // Similar reconnection logic for other errors
reconnectAttempt += 1 reconnectAttempt += 1
logger.info( logger.warning(
"Error during receive, attempting reconnection (\(reconnectAttempt)/\(reconnectionConfig.maxAttempts))..." "Error during receive, attempting reconnection (\(reconnectAttempt)/\(reconnectionConfig.maxAttempts))..."
) )

View file

@ -94,7 +94,7 @@ import struct Foundation.Data
try setNonBlocking(fileDescriptor: output) try setNonBlocking(fileDescriptor: output)
isConnected = true isConnected = true
logger.info("Transport connected successfully") logger.debug("Transport connected successfully")
// Start reading loop in background // Start reading loop in background
Task { Task {
@ -181,7 +181,7 @@ import struct Foundation.Data
guard isConnected else { return } guard isConnected else { return }
isConnected = false isConnected = false
messageContinuation.finish() messageContinuation.finish()
logger.info("Transport disconnected") logger.debug("Transport disconnected")
} }
/// Sends a message over the transport. /// Sends a message over the transport.

View file

@ -173,7 +173,7 @@ public actor Client {
self.connection = transport self.connection = transport
try await self.connection?.connect() try await self.connection?.connect()
await logger?.info( await logger?.debug(
"Client connected", metadata: ["name": "\(name)", "version": "\(version)"]) "Client connected", metadata: ["name": "\(name)", "version": "\(version)"])
// Start message handling loop // Start message handling loop
@ -216,7 +216,7 @@ public actor Client {
break break
} }
} while true } while true
await self.logger?.info("Client message handling loop task is terminating.") await self.logger?.debug("Client message handling loop task is terminating.")
} }
// Automatically initialize after connecting // Automatically initialize after connecting
@ -225,7 +225,7 @@ public actor Client {
/// Disconnect the client and cancel all pending requests /// Disconnect the client and cancel all pending requests
public func disconnect() async { public func disconnect() async {
await logger?.info("Initiating client disconnect...") await logger?.debug("Initiating client disconnect...")
// Part 1: Inside actor - Grab state and clear internal references // Part 1: Inside actor - Grab state and clear internal references
let taskToCancel = self.task let taskToCancel = self.task
@ -242,26 +242,26 @@ public actor Client {
for (_, request) in pendingRequestsToCancel { for (_, request) in pendingRequestsToCancel {
request.resume(throwing: MCPError.internalError("Client disconnected")) request.resume(throwing: MCPError.internalError("Client disconnected"))
} }
await logger?.info("Pending requests cancelled.") await logger?.debug("Pending requests cancelled.")
// Cancel the task // Cancel the task
taskToCancel?.cancel() taskToCancel?.cancel()
await logger?.info("Message loop task cancellation requested.") await logger?.debug("Message loop task cancellation requested.")
// Disconnect the transport *before* awaiting the task // Disconnect the transport *before* awaiting the task
// This should ensure the transport stream is finished, unblocking the loop. // This should ensure the transport stream is finished, unblocking the loop.
if let conn = connectionToDisconnect { if let conn = connectionToDisconnect {
await conn.disconnect() await conn.disconnect()
await logger?.info("Transport disconnected.") await logger?.debug("Transport disconnected.")
} else { } else {
await logger?.info("No active transport connection to disconnect.") await logger?.debug("No active transport connection to disconnect.")
} }
// Await the task completion *after* transport disconnect // Await the task completion *after* transport disconnect
_ = await taskToCancel?.value _ = await taskToCancel?.value
await logger?.info("Client message loop task finished.") await logger?.debug("Client message loop task finished.")
await logger?.info("Client disconnect complete.") await logger?.debug("Client disconnect complete.")
} }
// MARK: - Registration // MARK: - Registration
@ -468,7 +468,7 @@ public actor Client {
// Check if there are any requests to send // Check if there are any requests to send
guard !requests.isEmpty else { guard !requests.isEmpty else {
await logger?.info("Batch requested but no requests were added.") await logger?.debug("Batch requested but no requests were added.")
return // Nothing to send return // Nothing to send
} }

View file

@ -174,7 +174,7 @@ public actor Server {
registerDefaultHandlers(initializeHook: initializeHook) registerDefaultHandlers(initializeHook: initializeHook)
try await transport.connect() try await transport.connect()
await logger?.info( await logger?.debug(
"Server started", metadata: ["name": "\(name)", "version": "\(version)"]) "Server started", metadata: ["name": "\(name)", "version": "\(version)"])
// Start message handling loop // Start message handling loop
@ -227,7 +227,7 @@ public actor Server {
await logger?.error( await logger?.error(
"Fatal error in message handling loop", metadata: ["error": "\(error)"]) "Fatal error in message handling loop", metadata: ["error": "\(error)"])
} }
await logger?.info("Server finished", metadata: [:]) await logger?.debug("Server finished", metadata: [:])
} }
} }