From ccdd99aacc317ea02a7248cdb44933d4db552446 Mon Sep 17 00:00:00 2001 From: Alexander Emelin Date: Tue, 31 Oct 2023 07:25:16 +0200 Subject: [PATCH] improve logging for uni sse and uni http stream - avoid unnecessary errors --- internal/unihttpstream/handler.go | 2 +- internal/unisse/handler.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/unihttpstream/handler.go b/internal/unihttpstream/handler.go index db276219ef..eb3fd1c75a 100644 --- a/internal/unihttpstream/handler.go +++ b/internal/unihttpstream/handler.go @@ -36,11 +36,11 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { r.Body = http.MaxBytesReader(w, r.Body, maxBytesSize) connectRequestData, err := io.ReadAll(r.Body) if err != nil { + h.node.Log(centrifuge.NewLogEntry(centrifuge.LogLevelInfo, "error reading uni http stream request body", map[string]any{"error": err.Error()})) if len(connectRequestData) >= int(maxBytesSize) { w.WriteHeader(http.StatusRequestEntityTooLarge) return } - h.node.Log(centrifuge.NewLogEntry(centrifuge.LogLevelError, "error reading body", map[string]any{"error": err.Error()})) return } err = json.Unmarshal(connectRequestData, &req) diff --git a/internal/unisse/handler.go b/internal/unisse/handler.go index f6c84a1376..1b37e92f79 100644 --- a/internal/unisse/handler.go +++ b/internal/unisse/handler.go @@ -46,11 +46,11 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { r.Body = http.MaxBytesReader(w, r.Body, int64(maxBytesSize)) connectRequestData, err := io.ReadAll(r.Body) if err != nil { + h.node.Log(centrifuge.NewLogEntry(centrifuge.LogLevelInfo, "error reading uni sse request body", map[string]any{"error": err.Error()})) if len(connectRequestData) >= maxBytesSize { w.WriteHeader(http.StatusRequestEntityTooLarge) return } - h.node.Log(centrifuge.NewLogEntry(centrifuge.LogLevelError, "error reading body", map[string]any{"error": err.Error()})) return } err = json.Unmarshal(connectRequestData, &req)