Skip to content

Commit

Permalink
CASSGO-24 Global logger was removed
Browse files Browse the repository at this point in the history
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 for CASSGO-24
  • Loading branch information
tengu-alt committed Nov 13, 2024
1 parent 953e0df commit ccd50b0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Remove deprecated global logger [CASSGO-24](https://issues.apache.org/jira/browse/CASSGO-24)

### Fixed

## [1.7.0] - 2024-09-23
Expand Down
4 changes: 2 additions & 2 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ type ConnConfig struct {

func (c *ConnConfig) logger() StdLogger {
if c.Logger == nil {
return Logger
return &defaultLogger{}
}
return c.Logger
}
Expand Down
4 changes: 0 additions & 4 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}

0 comments on commit ccd50b0

Please sign in to comment.