Bug fix: Logger was being set to NOOP despite no logger being provided when debug mode is turned on.

This commit is contained in:
Renan DelValle 2018-04-16 16:54:53 -07:00
parent 7b1f51a747
commit 49e3194ba0
No known key found for this signature in database
GPG key ID: C240AD6D6F443EC9

View file

@ -250,7 +250,6 @@ func NewRealisClient(options ...ClientOption) (Realis, error) {
// Default configs
config.timeoutms = 10000
config.backoff = defaultBackoff
config.logger = LevelLogger{NoopLogger{}, false}
// Save options to recreate client if a connection error happens
config.options = options
@ -260,13 +259,15 @@ func NewRealisClient(options ...ClientOption) (Realis, error) {
opt(config)
}
config.logger.Println("Number of options applied to config: ", len(options))
// Set a logger if debug has been set to true but no logger has been set
// Set a logger if debug has been set to true but no logger has been set, otherwise, set noop logger
if config.logger == nil && config.debug {
config.logger = log.New(os.Stdout, "realis: ", log.Ltime|log.Ldate|log.LUTC)
} else if config.logger == nil {
config.logger = LevelLogger{NoopLogger{}, false}
}
config.logger.Println("Number of options applied to config: ", len(options))
//Set default Transport to JSON if needed.
if !config.jsonTransport && !config.binTransport {
config.jsonTransport = true