Skip to content

Commit

Permalink
Added auth user to log
Browse files Browse the repository at this point in the history
  • Loading branch information
msoap committed Dec 20, 2020
1 parent f6d86ac commit c205c3a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion http_middlewares.go
Expand Up @@ -77,7 +77,12 @@ func mwLogging(handler http.HandlerFunc) http.HandlerFunc {
rwLogger := &responseWriterLogger{srcRW: rw}
start := time.Now()
handler.ServeHTTP(rwLogger, req)
log.Printf(`%s %s "%s %s" %d %d "%s" %s`,
reqUser, _, ok := req.BasicAuth()
if ok {
reqUser += " "
}
log.Printf(`%s%s %s "%s %s" %d %d "%s" %s`,
reqUser,
req.Host, remoteAddr,
req.Method, req.RequestURI,
rwLogger.StatusCode(), rwLogger.Size(),
Expand Down

0 comments on commit c205c3a

Please sign in to comment.