From 6f71a2b812e792bff60fe8056aca18e6df6cd082 Mon Sep 17 00:00:00 2001 From: tengu-alt Date: Wed, 13 Nov 2024 14:48:02 +0200 Subject: [PATCH] Remove global logger MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By default, if the logger in the cluster config is not set, the NewSession() method sets a default logger instance which is a deprecated global variable. patch by Oleksandr Luzhniy; reviewed by João Reis, Stanislav Bychkov, for CASSGO-24 --- CHANGELOG.md | 2 ++ cluster.go | 4 ++-- conn.go | 2 +- logger.go | 4 ---- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20da746a0..b5f4087e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Don't restrict server authenticator unless PasswordAuthentictor.AllowedAuthenticators is provided (CASSGO-19) +- Remove deprecated global logger (CASSGO-24) + ### Fixed ## [1.7.0] - 2024-09-23 diff --git a/cluster.go b/cluster.go index 13e62f3b0..80cfb7e2a 100644 --- a/cluster.go +++ b/cluster.go @@ -254,7 +254,7 @@ type ClusterConfig struct { HostDialer HostDialer // Logger for this ClusterConfig. - // If not specified, defaults to the global gocql.Logger. + // If not specified, defaults to the gocql.defaultLogger. Logger StdLogger // internal config for testing @@ -298,7 +298,7 @@ func NewCluster(hosts ...string) *ClusterConfig { func (cfg *ClusterConfig) logger() StdLogger { if cfg.Logger == nil { - return Logger + return &defaultLogger{} } return cfg.Logger } diff --git a/conn.go b/conn.go index ae02bd71c..22b2cd7a2 100644 --- a/conn.go +++ b/conn.go @@ -151,7 +151,7 @@ type ConnConfig struct { func (c *ConnConfig) logger() StdLogger { if c.Logger == nil { - return Logger + return &defaultLogger{} } return c.Logger } diff --git a/logger.go b/logger.go index 246a117d7..1520111fc 100644 --- a/logger.go +++ b/logger.go @@ -58,7 +58,3 @@ type defaultLogger struct{} func (l *defaultLogger) Print(v ...interface{}) { log.Print(v...) } func (l *defaultLogger) Printf(format string, v ...interface{}) { log.Printf(format, v...) } func (l *defaultLogger) Println(v ...interface{}) { log.Println(v...) } - -// Logger for logging messages. -// Deprecated: Use ClusterConfig.Logger instead. -var Logger StdLogger = &defaultLogger{}