From 67b3d05a5d348ac855edbe70bda29a3ec9877bfe Mon Sep 17 00:00:00 2001 From: jianghang Date: Wed, 3 Aug 2022 17:04:42 +0800 Subject: [PATCH] Revert "Enable go-redis logger" This reverts commit a358354bc55dcb3c47b6c6db09a475a698a30ebf. Set global redis logger is not safe in multiple nodes situation. --- node.go | 3 --- redis_shard.go | 10 +++++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/node.go b/node.go index 59e066bc..a110f00b 100644 --- a/node.go +++ b/node.go @@ -11,8 +11,6 @@ import ( "sync" "time" - "github.com/go-redis/redis/v8" - "github.com/centrifugal/centrifuge/internal/controlpb" "github.com/centrifugal/centrifuge/internal/controlproto" "github.com/centrifugal/centrifuge/internal/dissolve" @@ -162,7 +160,6 @@ func New(c Config) (*Node, error) { if c.LogHandler != nil { n.logger = newLogger(c.LogLevel, c.LogHandler) } - redis.SetLogger(redisLogger{n}) b, err := NewMemoryBroker(n, MemoryBrokerConfig{}) if err != nil { diff --git a/redis_shard.go b/redis_shard.go index e128457f..4ed1bf38 100644 --- a/redis_shard.go +++ b/redis_shard.go @@ -38,12 +38,12 @@ const ( redisDataBatchLimit = 64 ) -type redisLogger struct{ - n *Node -} +type redisLogger struct{} + +func (redisLogger) Printf(ctx context.Context, format string, v ...interface{}) {} -func (l redisLogger) Printf(ctx context.Context, format string, v ...interface{}) { - l.n.Log(NewLogEntry(LogLevelInfo, fmt.Sprintf(format, v...))) +func init() { + redis.SetLogger(redisLogger{}) } type RedisShard struct {