Skip to content

Commit

Permalink
Add request_id in log
Browse files Browse the repository at this point in the history
  • Loading branch information
dynastymasra committed Mar 12, 2020
1 parent 8df16e2 commit 8851c82
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion negroni/middleware/logger.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package middleware

import (
"fmt"
"net/http"
"time"

Expand All @@ -11,10 +12,11 @@ import (
"github.com/urfave/negroni"
)

// LogrusLog middleware function for log HTTP request. combine with RequestID middleware first to add request id in log
func LogrusLog(name string) negroni.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
startTime := time.Now().UTC()
requestID := r.Header.Get(cookbook.XRequestID)
requestID := fmt.Sprint(r.Context().Value(RequestID))

next(w, r)

Expand Down

0 comments on commit 8851c82

Please sign in to comment.