Skip to content

Commit 907ac2e

Browse files
committed
fix: Slf4jLoggingConsumer uses specific Logger
See also modelcontextprotocol/java-sdk#503 and google/adk-java#370.
1 parent ffc0046 commit 907ac2e

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

java/dev/enola/ai/mcp/McpLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private static McpSyncClient createSyncClient(McpClientTransport transport, Stri
124124
// TODO Make this configurable - but how & from where?
125125
// .initializationTimeout(Duration.ofSeconds(7))
126126
// .requestTimeout(Duration.ofSeconds(7))
127-
.loggingConsumer(new McpServer(origin))
127+
.loggingConsumer(new Slf4jLoggingConsumer(origin))
128128
.build();
129129
client.initialize();
130130
client.ping();

java/dev/enola/ai/mcp/McpServer.java renamed to java/dev/enola/ai/mcp/Slf4jLoggingConsumer.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,22 @@
2626

2727
import java.util.function.Consumer;
2828

29-
class McpServer implements Consumer<LoggingMessageNotification> {
29+
class Slf4jLoggingConsumer implements Consumer<LoggingMessageNotification> {
3030

31-
private static final Logger LOG = LoggerFactory.getLogger(McpServer.class);
31+
// TODO: If https://github.com/modelcontextprotocol/java-sdk/pull/503
32+
// is accepted and merged, the eventually replace this by that?
33+
// But that doesn't have the origin... hm. Add it?
3234

3335
private final String origin;
3436

35-
public McpServer(String origin) {
37+
public Slf4jLoggingConsumer(String origin) {
3638
this.origin = origin;
3739
}
3840

3941
@Override
4042
public void accept(LoggingMessageNotification notif) {
41-
LOG.atLevel(convert(notif.level()))
43+
Logger log = LoggerFactory.getLogger(notif.logger());
44+
log.atLevel(convert(notif.level()))
4245
.log("{} : {} : {}", origin, notif.logger(), notif.data());
4346
}
4447

0 commit comments

Comments
 (0)