+ }
+
+ if rawQuery != "" {
+ path = fmt.Sprintf("%s?%s", path, rawQuery)
+ }
+
+ l = l.WithField("path", path)
+
+ msgLog := fmt.Sprintf("[%v] %d %s '%s'", latency, code, c.Request.Method, path)
+
+ var level logrus.Level
+ switch {
+ case code >= 200 && code < 400:
+ level = logrus.DebugLevel
+ case code >= 400 && code < 500:
+ level = logrus.InfoLevel
+ default:
+ level = logrus.ErrorLevel
+ }
+
+ errors := c.Errors.ByType(gin.ErrorTypePrivate)
+
+ for _, err := range errors {
+ l.WithField("description", err.Err).Logf(level, "%s: %s", msgLog, err.Err)
+ }