Skip to content

Commit

Permalink
fix: default x-log-level should be info
Browse files Browse the repository at this point in the history
  • Loading branch information
morlay committed Jul 26, 2023
1 parent 64af41e commit e7933b1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/http/middleware/otel_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,13 @@ func LogAndMetricHandler() func(handler http.Handler) http.Handler {

nextHandler.ServeHTTP(loggerRw, req.WithContext(ctx))

enabledLevel, _ := logr.ParseLevel(strings.ToLower(req.Header.Get("x-log-level")))
enabledLevel := logr.InfoLevel
if logLevel := req.Header.Get("x-log-level"); logLevel != "" {
lvl, err := logr.ParseLevel(strings.ToLower(logLevel))
if err == nil {
enabledLevel = lvl
}
}

requestCost := time.Since(startAt)
requestHeader := req.Header
Expand Down

0 comments on commit e7933b1

Please sign in to comment.