[#396] Add user to response
All checks were successful
/ DCO (pull_request) Successful in 1m51s
/ Builds (1.20) (pull_request) Successful in 2m18s
/ Builds (1.21) (pull_request) Successful in 2m3s
/ Vulncheck (pull_request) Successful in 1m58s
/ Lint (pull_request) Successful in 3m52s
/ Tests (1.20) (pull_request) Successful in 2m40s
/ Tests (1.21) (pull_request) Successful in 2m30s

Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
This commit is contained in:
Pavel Pogodaev 2024-05-27 17:41:32 +03:00
parent 9787b29542
commit cbed408670
2 changed files with 4 additions and 0 deletions

View file

@ -42,6 +42,7 @@ func (h *handler) logAndSendError(w http.ResponseWriter, logText string, reqInfo
zap.String("bucket", reqInfo.BucketName), zap.String("bucket", reqInfo.BucketName),
zap.String("object", reqInfo.ObjectName), zap.String("object", reqInfo.ObjectName),
zap.String("description", logText), zap.String("description", logText),
zap.String("user", reqInfo.User),
zap.Error(err)} zap.Error(err)}
fields = append(fields, additional...) fields = append(fields, additional...)
if traceID, err := trace.TraceIDFromHex(reqInfo.TraceID); err == nil && traceID.IsValid() { if traceID, err := trace.TraceIDFromHex(reqInfo.TraceID); err == nil && traceID.IsValid() {

View file

@ -328,6 +328,9 @@ func LogSuccessResponse(l *zap.Logger) Func {
if reqInfo.ObjectName != "" { if reqInfo.ObjectName != "" {
fields = append(fields, zap.String("object", 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() { if traceID, err := trace.TraceIDFromHex(reqInfo.TraceID); err == nil && traceID.IsValid() {
fields = append(fields, zap.String("trace_id", reqInfo.TraceID)) fields = append(fields, zap.String("trace_id", reqInfo.TraceID))