Skip to content

Commit

Permalink
support log level as dynamic config
Browse files Browse the repository at this point in the history
Signed-off-by: aoiasd <[email protected]>
  • Loading branch information
aoiasd committed Jul 17, 2024
1 parent 1fd477d commit ab62f5a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/roles/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"

"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
"github.com/milvus-io/milvus/cmd/components"
Expand Down Expand Up @@ -249,6 +250,16 @@ func (mr *MilvusRoles) setupLogger() {
}

logutil.SetupLogger(&logConfig)

params.Watch(params.LogCfg.Level.Key, config.NewHandler("log level handler", func(e *config.Event) {
level := zapcore.DebugLevel
if err := level.UnmarshalText([]byte(e.Value)); err != nil {
log.Warn("update log level failed", zap.String("level", e.Value), zap.Error(err))
return
}
log.SetLevel(level)
log.Info("update log level", zap.String("level", e.Value))
}))
}

// Register serves prometheus http service
Expand Down

0 comments on commit ab62f5a

Please sign in to comment.