Skip to content

Commit 3bd1594

Browse files
committed
Remove global logger
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
1 parent 37030fb commit 3bd1594

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818

1919
- Change Batch API to be consistent with Query() (CASSGO-7)
2020

21+
- Remove deprecated global logger (CASSGO-24)
22+
2123
### Fixed
2224

2325
- Retry policy now takes into account query idempotency (CASSGO-27)

cluster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ type ClusterConfig struct {
260260
HostDialer HostDialer
261261

262262
// Logger for this ClusterConfig.
263-
// If not specified, defaults to the global gocql.Logger.
263+
// If not specified, defaults to the gocql.defaultLogger.
264264
Logger StdLogger
265265

266266
// internal config for testing
@@ -304,7 +304,7 @@ func NewCluster(hosts ...string) *ClusterConfig {
304304

305305
func (cfg *ClusterConfig) logger() StdLogger {
306306
if cfg.Logger == nil {
307-
return Logger
307+
return &defaultLogger{}
308308
}
309309
return cfg.Logger
310310
}

conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ type ConnConfig struct {
151151

152152
func (c *ConnConfig) logger() StdLogger {
153153
if c.Logger == nil {
154-
return Logger
154+
return &defaultLogger{}
155155
}
156156
return c.Logger
157157
}

logger.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,3 @@ type defaultLogger struct{}
5858
func (l *defaultLogger) Print(v ...interface{}) { log.Print(v...) }
5959
func (l *defaultLogger) Printf(format string, v ...interface{}) { log.Printf(format, v...) }
6060
func (l *defaultLogger) Println(v ...interface{}) { log.Println(v...) }
61-
62-
// Logger for logging messages.
63-
// Deprecated: Use ClusterConfig.Logger instead.
64-
var Logger StdLogger = &defaultLogger{}

0 commit comments

Comments
 (0)