From 5b2110eb9832630c0e395caea291c73fe92826d7 Mon Sep 17 00:00:00 2001 From: OpenClaw Agent Date: Mon, 21 Sep 2026 16:14:46 +0800 Subject: [PATCH] fix: restore operation logging hook --- chfs-ng/internal/api/server.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/chfs-ng/internal/api/server.go b/chfs-ng/internal/api/server.go index 649bacb..5d58f6a 100644 --- a/chfs-ng/internal/api/server.go +++ b/chfs-ng/internal/api/server.go @@ -85,6 +85,26 @@ func account(r *http.Request, s *Server) *auth.Account { return s.Auth.Guest } +func (s *Server) logOp(r *http.Request, action string) { + if s.Log == nil { + return + } + a := account(r, s) + user := "" + if a != nil { + user = a.Username + } + _ = s.Log.Write(clientIPString(r), user, action) +} + +func clientIPString(r *http.Request) string { + ip := clientIP(r) + if ip == nil { + return "-" + } + return ip.String() +} + func writeJSON(w http.ResponseWriter, v any) { w.Header().Set("Content-Type", "application/json; charset=utf-8") json.NewEncoder(w).Encode(v)