include self addr in logging

This commit is contained in:
Branden J Brown 2025-03-15 20:46:37 -04:00
parent af65c66317
commit dd75fb281a
3 changed files with 8 additions and 3 deletions

View File

@ -13,8 +13,9 @@ import (
"path"
"strings"
"git.sunturtle.xyz/zephyr/chord/chord"
"github.com/go-json-experiment/json"
"git.sunturtle.xyz/zephyr/chord/chord"
)
type Client struct {

View File

@ -77,7 +77,7 @@ func (n *Node) Check(ctx context.Context) error {
func (n *Node) find(w http.ResponseWriter, r *http.Request) {
s := r.PathValue("id")
slog.DebugContext(r.Context(), "received find", slog.String("id", s), slog.String("from", r.RemoteAddr))
slog.DebugContext(r.Context(), "received find", slog.String("node", n.self.String()), slog.String("id", s), slog.String("from", r.RemoteAddr))
id, err := chord.ParseID(s)
if err != nil {
writeError(w, http.StatusBadRequest, err.Error())
@ -89,7 +89,7 @@ func (n *Node) find(w http.ResponseWriter, r *http.Request) {
return
}
_, addr := p.Values()
slog.DebugContext(r.Context(), "tell found", slog.String("id", s), slog.String("addr", addr.String()))
slog.DebugContext(r.Context(), "tell found", slog.String("node", n.self.String()), slog.String("id", s), slog.String("addr", addr.String()))
writeOk(w, addr)
}

View File

@ -168,6 +168,10 @@ func (n *Node) SuccessorFailed() {
n.succ[0] = n.self
}
func (n *Node) String() string {
return n.self.String()
}
// Peer is the ID and address of a node.
type Peer struct {
id ID