in logger.go [29:57]
func logrusMiddleware(c *gin.Context) {
start := time.Now()
method := c.Request.Method
path := c.Request.URL.Path
if rawQuery := c.Request.URL.RawQuery; rawQuery != "" {
path += "?" + rawQuery
}
c.Next()
logger := contextLogger(c)
status := c.Writer.Status()
entry := logger.WithFields(logrus.Fields{
"path": path,
"method": method,
"duration": time.Since(start),
"client-ip": c.ClientIP(),
"status": status,
})
entry.Time = start
logf := entry.Infof
switch {
case status >= http.StatusInternalServerError:
logf = entry.Errorf
case status >= http.StatusBadRequest:
logf = entry.Warningf
}
logf("%s %s (%d)", c.Request.Method, c.Request.URL.Path, status)
}