From b5fae316cf5925bf4b26ff764d8640a3976f2430 Mon Sep 17 00:00:00 2001
From: Pavel Pogodaev
Date: Mon, 27 May 2024 17:41:32 +0300
Subject: [PATCH] [#396] Add user to response
Signed-off-by: Pavel Pogodaev
---
api/handler/util.go | 1 +
api/middleware/response.go | 3 +++
2 files changed, 4 insertions(+)
diff --git a/api/handler/util.go b/api/handler/util.go
index 591837b..41fe57a 100644
--- a/api/handler/util.go
+++ b/api/handler/util.go
@@ -42,6 +42,7 @@ func (h *handler) logAndSendError(w http.ResponseWriter, logText string, reqInfo
zap.String("bucket", reqInfo.BucketName),
zap.String("object", reqInfo.ObjectName),
zap.String("description", logText),
+ zap.String("user", reqInfo.User),
zap.Error(err)}
fields = append(fields, additional...)
if traceID, err := trace.TraceIDFromHex(reqInfo.TraceID); err == nil && traceID.IsValid() {
diff --git a/api/middleware/response.go b/api/middleware/response.go
index 085a97c..b94b403 100644
--- a/api/middleware/response.go
+++ b/api/middleware/response.go
@@ -328,6 +328,9 @@ func LogSuccessResponse(l *zap.Logger) Func {
if reqInfo.ObjectName != "" {
fields = append(fields, zap.String("object", reqInfo.ObjectName))
}
+ if reqInfo.User != "" {
+ fields = append(fields, zap.String("user", reqInfo.User))
+ }
if traceID, err := trace.TraceIDFromHex(reqInfo.TraceID); err == nil && traceID.IsValid() {
fields = append(fields, zap.String("trace_id", reqInfo.TraceID))