Skip to content

Commit

Permalink
api: change loglevel (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhebox authored Jun 8, 2023
1 parent d507def commit 66d42d5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pkg/server/api/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ func (h *HTTPServer) rateLimit(c *gin.Context) {

func (h *HTTPServer) attachLogger(c *gin.Context) {
path := c.Request.URL.Path
if strings.HasPrefix(path, "/api/debug/health") {
return
}

fields := make([]zapcore.Field, 0, 9)

Expand Down Expand Up @@ -148,7 +145,13 @@ func (h *HTTPServer) attachLogger(c *gin.Context) {
fields = append(fields, zap.Errors("errs", errs))
}

h.lg.Info(path, fields...)
if len(c.Errors) > 0 {
h.lg.Warn(path, fields...)
} else if strings.HasPrefix(path, "/api/debug") || strings.HasPrefix(path, "/api/metrics") {
h.lg.Debug(path, fields...)
} else {
h.lg.Info(path, fields...)
}
}

func (h *HTTPServer) readyState(c *gin.Context) {
Expand Down

0 comments on commit 66d42d5

Please sign in to comment.