- for _, err := range c.Errors {
- l := log.WithField("path", path)
+ latency := time.Now().Sub(start).Round(10 * time.Microsecond)
+ code := c.Writer.Status()
+
+ l := log
+ l = l.WithField("latency", latency)
+ l = l.WithField("client_ip", c.ClientIP())
+ l = l.WithField("method", c.Request.Method)
+ l = l.WithField("status_code", code)
+
+ if _, exists := c.Get("user"); exists {
+ l = l.WithField("user_id", GetUser(c).Id)
+ }
+
+ if rawQuery != "" {
+ path = fmt.Sprintf("%s?%s", path, rawQuery)
+ }
+
+ l = l.WithField("path", path)