11package redis_test
22
33import (
4+ "context"
45 "fmt"
56 "net"
67 "os"
@@ -13,6 +14,7 @@ import (
1314 . "github.com/bsm/ginkgo/v2"
1415 . "github.com/bsm/gomega"
1516 "github.com/redis/go-redis/v9"
17+ "github.com/redis/go-redis/v9/internal"
1618)
1719
1820const (
@@ -103,9 +105,11 @@ var _ = BeforeSuite(func() {
103105 fmt .Printf ("REDIS_VERSION: %.1f\n " , RedisVersion )
104106 fmt .Printf ("CLIENT_LIBS_TEST_IMAGE: %v\n " , os .Getenv ("CLIENT_LIBS_TEST_IMAGE" ))
105107
106- tlogger := & TestLogger {}
108+ // set logger that will filter some of the noise from the tests
109+ tlogger := NewTestLogger ()
107110 tlogger .Filter ("ERR unknown subcommand 'maint_notifications'" )
108111 redis .SetLogger (tlogger )
112+
109113 if RedisVersion < 7.0 || RedisVersion > 9 {
110114 panic ("incorrect or not supported redis version" )
111115 }
@@ -403,20 +407,30 @@ func (h *hook) ProcessPipelineHook(hook redis.ProcessPipelineHook) redis.Process
403407 return hook
404408}
405409
410+ func NewTestLogger () * TestLogger {
411+ intLogger := internal .Logger
412+
413+ return & TestLogger {
414+ intLogger ,
415+ []string {},
416+ }
417+ }
418+
406419// TestLogger is a logger that filters out specific substrings so
407420// the test output is not polluted with noise.
408421type TestLogger struct {
422+ intLogger internal.Logging
409423 filteredSugstrings []string
410424}
411425
412426func (t * TestLogger ) Filter (substr string ) {
413427 t .filteredSugstrings = append (t .filteredSugstrings , substr )
414428}
415- func (t * TestLogger ) Printf (ctx context.Context , format string , v ... interface {}) {
429+ func (t * TestLogger ) Printf (_ context.Context , format string , v ... interface {}) {
416430 for _ , substr := range t .filteredSugstrings {
417431 if strings .Contains (format , substr ) {
418432 return
419433 }
420434 }
421- fmt . Printf (format , v ... )
435+ t . intLogger . Printf (ctx , format , v ... )
422436}
0 commit comments