Skip to content

Find, verify, and analyze leaked credentials

Remove unused findLevel function (#3628)

Miccah1018e0095f37
diff --git a/pkg/log/level.go b/pkg/log/level.go
index d3c23b078..9dd8f4f32 100644
--- a/pkg/log/level.go
+++ b/pkg/log/level.go
@@ -1,9 +1,6 @@
package log
import (
- "sort"
-
- "github.com/go-logr/logr"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
@@ -32,12 +29,3 @@ func SetLevelForControl(control levelSetter, level int8) {
// For example setting the level to -2 below, means log.V(2) will be enabled.
control.SetLevel(zapcore.Level(-level))
}
-
-// findLevel probes a logr.Logger to figure out what level it is at via binary
-// search. We only search [0, 128), so worst case is ~7 checks.
-func findLevel(logger logr.Logger) int8 {
- sink := logger.GetSink()
- return int8(sort.Search(128, func(i int) bool {
- return !sink.Enabled(i)
- }) - 1)
-}
diff --git a/pkg/log/log_test.go b/pkg/log/log_test.go
index f1dced5e4..b1827b5d8 100644
--- a/pkg/log/log_test.go
+++ b/pkg/log/log_test.go
@@ -224,17 +224,6 @@ func splitLines(s string) []string {
return logLines
}
-func TestFindLevel(t *testing.T) {
- lvl := zap.NewAtomicLevel()
- logger, _ := New("parent", WithConsoleSink(io.Discard, WithLeveler(lvl)))
-
- for i := 0; i < 128; i++ {
- i8 := int8(i)
- SetLevelForControl(lvl, i8)
- assert.Equal(t, i8, findLevel(logger))
- }
-}
-
func TestGlobalRedaction_Console(t *testing.T) {
oldState := globalRedactor
globalRedactor = &dynamicRedactor{