Skip to content

Commit 9ad382d

Browse files
authored
remove info level logging message and use debug instead (#132)
1 parent f3b9ba4 commit 9ad382d

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

Sources/MCP/Base/Transports/HTTPClientTransport.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public actor HTTPClientTransport: Transport {
152152
streamingTask = Task { await startListeningForServerEvents() }
153153
}
154154

155-
logger.info("HTTP transport connected")
155+
logger.debug("HTTP transport connected")
156156
}
157157

158158
/// Disconnects from the transport
@@ -180,7 +180,7 @@ public actor HTTPClientTransport: Transport {
180180
initialSessionIDContinuation?.resume()
181181
initialSessionIDContinuation = nil
182182

183-
logger.info("HTTP clienttransport disconnected")
183+
logger.debug("HTTP clienttransport disconnected")
184184
}
185185

186186
/// Sends data through an HTTP POST request
@@ -440,7 +440,7 @@ public actor HTTPClientTransport: Transport {
440440
"Initial sessionID already available. Proceeding with SSE streaming task immediately."
441441
)
442442
} else {
443-
logger.info(
443+
logger.trace(
444444
"Proceeding with SSE connection attempt; sessionID is nil. This might be expected for stateless servers or if initialize hasn't provided one yet."
445445
)
446446
}

Sources/MCP/Base/Transports/NetworkTransport.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ import Logging
368368

369369
// Reset reconnect attempt counter on successful connection
370370
reconnectAttempt = 0
371-
logger.info("Network transport connected successfully")
371+
logger.debug("Network transport connected successfully")
372372
continuation.resume()
373373

374374
// Start the receive loop after connection is established
@@ -498,7 +498,7 @@ import Logging
498498
{
499499
// Try to reconnect with exponential backoff
500500
reconnectAttempt += 1
501-
logger.info(
501+
logger.debug(
502502
"Attempting reconnection after \(context) (\(reconnectAttempt)/\(reconnectionConfig.maxAttempts))..."
503503
)
504504

@@ -541,7 +541,7 @@ import Logging
541541

542542
connection.cancel()
543543
messageContinuation.finish()
544-
logger.info("Network transport disconnected")
544+
logger.debug("Network transport disconnected")
545545
}
546546

547547
/// Sends data through the network connection
@@ -658,7 +658,7 @@ import Logging
658658

659659
// Check connection state
660660
if connection.state != .ready {
661-
logger.info("Connection no longer ready, exiting receive loop")
661+
logger.warning("Connection no longer ready, exiting receive loop")
662662
break
663663
}
664664
}
@@ -708,7 +708,7 @@ import Logging
708708
&& reconnectAttempt < reconnectionConfig.maxAttempts
709709
{
710710
reconnectAttempt += 1
711-
logger.info(
711+
logger.warning(
712712
"Network connection lost, attempting reconnection (\(reconnectAttempt)/\(reconnectionConfig.maxAttempts))..."
713713
)
714714

@@ -759,7 +759,7 @@ import Logging
759759
{
760760
// Similar reconnection logic for other errors
761761
reconnectAttempt += 1
762-
logger.info(
762+
logger.warning(
763763
"Error during receive, attempting reconnection (\(reconnectAttempt)/\(reconnectionConfig.maxAttempts))..."
764764
)
765765

Sources/MCP/Base/Transports/StdioTransport.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ import struct Foundation.Data
9494
try setNonBlocking(fileDescriptor: output)
9595

9696
isConnected = true
97-
logger.info("Transport connected successfully")
97+
logger.debug("Transport connected successfully")
9898

9999
// Start reading loop in background
100100
Task {
@@ -181,7 +181,7 @@ import struct Foundation.Data
181181
guard isConnected else { return }
182182
isConnected = false
183183
messageContinuation.finish()
184-
logger.info("Transport disconnected")
184+
logger.debug("Transport disconnected")
185185
}
186186

187187
/// Sends a message over the transport.

Sources/MCP/Client/Client.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public actor Client {
173173
self.connection = transport
174174
try await self.connection?.connect()
175175

176-
await logger?.info(
176+
await logger?.debug(
177177
"Client connected", metadata: ["name": "\(name)", "version": "\(version)"])
178178

179179
// Start message handling loop
@@ -216,7 +216,7 @@ public actor Client {
216216
break
217217
}
218218
} while true
219-
await self.logger?.info("Client message handling loop task is terminating.")
219+
await self.logger?.debug("Client message handling loop task is terminating.")
220220
}
221221

222222
// Automatically initialize after connecting
@@ -225,7 +225,7 @@ public actor Client {
225225

226226
/// Disconnect the client and cancel all pending requests
227227
public func disconnect() async {
228-
await logger?.info("Initiating client disconnect...")
228+
await logger?.debug("Initiating client disconnect...")
229229

230230
// Part 1: Inside actor - Grab state and clear internal references
231231
let taskToCancel = self.task
@@ -242,26 +242,26 @@ public actor Client {
242242
for (_, request) in pendingRequestsToCancel {
243243
request.resume(throwing: MCPError.internalError("Client disconnected"))
244244
}
245-
await logger?.info("Pending requests cancelled.")
245+
await logger?.debug("Pending requests cancelled.")
246246

247247
// Cancel the task
248248
taskToCancel?.cancel()
249-
await logger?.info("Message loop task cancellation requested.")
249+
await logger?.debug("Message loop task cancellation requested.")
250250

251251
// Disconnect the transport *before* awaiting the task
252252
// This should ensure the transport stream is finished, unblocking the loop.
253253
if let conn = connectionToDisconnect {
254254
await conn.disconnect()
255-
await logger?.info("Transport disconnected.")
255+
await logger?.debug("Transport disconnected.")
256256
} else {
257-
await logger?.info("No active transport connection to disconnect.")
257+
await logger?.debug("No active transport connection to disconnect.")
258258
}
259259

260260
// Await the task completion *after* transport disconnect
261261
_ = await taskToCancel?.value
262-
await logger?.info("Client message loop task finished.")
262+
await logger?.debug("Client message loop task finished.")
263263

264-
await logger?.info("Client disconnect complete.")
264+
await logger?.debug("Client disconnect complete.")
265265
}
266266

267267
// MARK: - Registration
@@ -468,7 +468,7 @@ public actor Client {
468468

469469
// Check if there are any requests to send
470470
guard !requests.isEmpty else {
471-
await logger?.info("Batch requested but no requests were added.")
471+
await logger?.debug("Batch requested but no requests were added.")
472472
return // Nothing to send
473473
}
474474

Sources/MCP/Server/Server.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public actor Server {
174174
registerDefaultHandlers(initializeHook: initializeHook)
175175
try await transport.connect()
176176

177-
await logger?.info(
177+
await logger?.debug(
178178
"Server started", metadata: ["name": "\(name)", "version": "\(version)"])
179179

180180
// Start message handling loop
@@ -227,7 +227,7 @@ public actor Server {
227227
await logger?.error(
228228
"Fatal error in message handling loop", metadata: ["error": "\(error)"])
229229
}
230-
await logger?.info("Server finished", metadata: [:])
230+
await logger?.debug("Server finished", metadata: [:])
231231
}
232232
}
233233

0 commit comments

Comments
 (0)