Skip to content

Commit ef2bc39

Browse files
authored
added request method in audit logger (#4817)
1 parent d68d034 commit ef2bc39

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

api/util/logger.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type AuditLoggerDTO struct {
1818
QueryParams string `json:"queryParams"`
1919
ApiResponseCode int `json:"apiResponseCode"`
2020
RequestPayload []byte `json:"requestPayload"`
21+
RequestMethod string `json:"requestMethod"`
2122
}
2223

2324
type LoggingMiddlewareImpl struct {
@@ -61,6 +62,7 @@ func (impl LoggingMiddlewareImpl) LoggingMiddleware(next http.Handler) http.Hand
6162
UpdatedOn: time.Now(),
6263
QueryParams: r.URL.Query().Encode(),
6364
RequestPayload: bodyBuffer.Bytes(),
65+
RequestMethod: r.Method,
6466
}
6567
// Call the next handler in the chain.
6668
next.ServeHTTP(d, r)
@@ -71,5 +73,5 @@ func (impl LoggingMiddlewareImpl) LoggingMiddleware(next http.Handler) http.Hand
7173
}
7274

7375
func LogRequest(auditLogDto *AuditLoggerDTO) {
74-
log.Printf("AUDIT_LOG: urlPath: %s, queryParams: %s,updatedBy: %s, updatedOn: %s, apiResponseCode: %d,requestPayload: %s", auditLogDto.UrlPath, auditLogDto.QueryParams, auditLogDto.UserEmail, auditLogDto.UpdatedOn, auditLogDto.ApiResponseCode, auditLogDto.RequestPayload)
76+
log.Printf("AUDIT_LOG: requestMethod: %s, urlPath: %s, queryParams: %s, updatedBy: %s, updatedOn: %s, apiResponseCode: %d, requestPayload: %s", auditLogDto.RequestMethod, auditLogDto.UrlPath, auditLogDto.QueryParams, auditLogDto.UserEmail, auditLogDto.UpdatedOn, auditLogDto.ApiResponseCode, auditLogDto.RequestPayload)
7577
}

0 commit comments

Comments
 (0)