From 49e3194ba0a6c30931b75c69c0c0ac57fc62ebe5 Mon Sep 17 00:00:00 2001 From: Renan DelValle Date: Mon, 16 Apr 2018 16:54:53 -0700 Subject: [PATCH] Bug fix: Logger was being set to NOOP despite no logger being provided when debug mode is turned on. --- realis.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/realis.go b/realis.go index f1cb09f..a697a60 100644 --- a/realis.go +++ b/realis.go @@ -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