mcp: fix stray log.Printf in notifySessions
I encountered these logs, and they were distracting and noisy. We shouldn't log to stderr unless configured by the user. Thread through the logger. Also, use ensureLogger in the streamable client to simplify call sites. Updates #708 Updates #684
This commit is contained in:
parent
b012d0824e
commit
6f6e196c27
1 changed files with 13 additions and 14 deletions
|
|
@ -15,7 +15,7 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"slices"
|
||||
|
|
@ -381,7 +381,8 @@ const (
|
|||
|
||||
// notifySessions calls Notify on all the sessions.
|
||||
// Should be called on a copy of the peer sessions.
|
||||
func notifySessions[S Session, P Params](sessions []S, method string, params P) {
|
||||
// The logger must be non-nil.
|
||||
func notifySessions[S Session, P Params](sessions []S, method string, params P, logger *slog.Logger) {
|
||||
if sessions == nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -394,8 +395,7 @@ func notifySessions[S Session, P Params](sessions []S, method string, params P)
|
|||
for _, s := range sessions {
|
||||
req := newRequest(s, params)
|
||||
if err := handleNotify(ctx, method, req); err != nil {
|
||||
// TODO(#218): surface this error better
|
||||
log.Printf("calling %s: %v", method, err)
|
||||
logger.Warn(fmt.Sprintf("calling %s: %v", method, err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue