diff --git a/pkg/tools/log/logruslogger/levelchange.go b/pkg/tools/log/logruslogger/levelchange.go index a8c8b8593..b2edc70eb 100644 --- a/pkg/tools/log/logruslogger/levelchange.go +++ b/pkg/tools/log/logruslogger/levelchange.go @@ -29,21 +29,19 @@ import ( // SetupLevelChangeOnSignal sets the loglevel to the one specified in the map when a signal assotiated to it arrives func SetupLevelChangeOnSignal(ctx context.Context, signals map[os.Signal]logrus.Level) { - if len(signals) < 2 { - log.FromContext(ctx).Info("map size < 2, disabling loglevel change on signal") - return - } - vals := []logrus.Level{} - for _, v := range signals { - vals = append(vals, v) - } - sort.Slice(vals, func(i, j int) bool { return i < j }) - for i := 0; i < len(vals)-1; i++ { - if vals[i] == vals[i+1] { - log.FromContext(ctx).Info("duplicate values found in map, disabling loglevel change on signal") - return - } - } +var currentLevelCount int + +for _, v := range signals{ + if v == logrus.GetLevel() { + currentLevelCount++ + } +} + +if currentLevelCount == len(signals) { + + log.FromContext(ctx).WithField("logruslogger","SetupLevelChangeOnSignal").Warn("detected that log level will never changed, disabling loglevel change on signal") + return +} sigChannel := make(chan os.Signal, len(signals)) for sig := range signals { signal.Notify(sigChannel, sig)