From 06aca66c4069a0ea0115f0738d9949604ca5ac2b Mon Sep 17 00:00:00 2001 From: Nikita Zinkevich Date: Wed, 24 Jul 2024 11:35:42 +0300 Subject: [PATCH] [#369] Add base64 encoding of body Signed-off-by: Nikita Zinkevich --- api/middleware/log_http.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/middleware/log_http.go b/api/middleware/log_http.go index 477689b6..8529717c 100644 --- a/api/middleware/log_http.go +++ b/api/middleware/log_http.go @@ -4,6 +4,7 @@ package middleware import ( "bytes" + "encoding/base64" "fmt" "io" "net/http" @@ -156,7 +157,7 @@ func withBody(httplog *zap.Logger, r *http.Request) (*zap.Logger, error) { defer r.Body.Close() r.Body = io.NopCloser(bytes.NewBuffer(body)) - httplog = httplog.With(zap.String("body", string(body))) + httplog = httplog.With(zap.String("body", base64.StdEncoding.EncodeToString(body))) return httplog, nil }