diff --git a/chord/httpnode/client.go b/chord/httpnode/client.go index a5f56b1..d9a59a4 100644 --- a/chord/httpnode/client.go +++ b/chord/httpnode/client.go @@ -5,6 +5,7 @@ import ( "encoding/base64" "errors" "fmt" + "log/slog" "net/http" "net/url" "path" @@ -35,6 +36,7 @@ func (cl *Client) Find(ctx context.Context, s chord.Peer, id chord.ID) (chord.Pe if err != nil { return chord.Peer{}, "", err } + slog.InfoContext(ctx, "find", slog.String("url", url.String())) resp, err := cl.HTTP.Do(req) if err != nil { return chord.Peer{}, "", err @@ -43,6 +45,7 @@ func (cl *Client) Find(ctx context.Context, s chord.Peer, id chord.ID) (chord.Pe if err != nil { return chord.Peer{}, "", fmt.Errorf("%w (%s)", err, resp.Status) } + slog.InfoContext(ctx, "found", slog.String("peer", p.Peer.String()), slog.String("value", p.Value)) return chord.Address(p.Peer), p.Value, nil } diff --git a/chord/httpnode/server.go b/chord/httpnode/server.go index 050763e..64f7731 100644 --- a/chord/httpnode/server.go +++ b/chord/httpnode/server.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "io" + "log/slog" "net" "net/http" "net/netip" @@ -67,6 +68,7 @@ func (n *Node) Check(ctx context.Context) error { func (n *Node) key(w http.ResponseWriter, r *http.Request) { s := r.PathValue("id") + slog.InfoContext(r.Context(), "received find", slog.String("id", s), slog.String("from", r.RemoteAddr)) id, err := chord.ParseID(s) if err != nil { writeError(w, http.StatusBadRequest, err.Error()) @@ -78,6 +80,7 @@ func (n *Node) key(w http.ResponseWriter, r *http.Request) { return } _, addr := p.Values() + slog.InfoContext(r.Context(), "tell found", slog.String("id", s), slog.String("addr", addr.String()), slog.String("value", v)) pv := peervalue{addr, v} writeOk(w, pv) }