Turn on logging by default.

This commit is contained in:
Renan DelValle 2018-04-16 17:54:41 -07:00
parent 49e3194ba0
commit d64a91784a
No known key found for this signature in database
GPG key ID: C240AD6D6F443EC9
2 changed files with 4 additions and 8 deletions

View file

@ -18,7 +18,6 @@ import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"time"
@ -90,7 +89,6 @@ func main() {
Factor: 2.0,
Jitter: 0.1,
}),
realis.SetLogger(log.New(os.Stdout, "realis-debug: ", log.Ldate)),
realis.Debug(),
}

View file

@ -27,9 +27,8 @@ import (
"os"
"path/filepath"
"strings"
"time"
"sync"
"time"
"git.apache.org/thrift.git/lib/go/thrift"
"github.com/paypal/gorealis/gen-go/apache/aurora"
@ -250,6 +249,7 @@ func NewRealisClient(options ...ClientOption) (Realis, error) {
// Default configs
config.timeoutms = 10000
config.backoff = defaultBackoff
config.logger = log.New(os.Stdout, "realis: ", log.Ltime|log.Ldate|log.LUTC)
// Save options to recreate client if a connection error happens
config.options = options
@ -259,10 +259,8 @@ func NewRealisClient(options ...ClientOption) (Realis, error) {
opt(config)
}
// 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 {
// Turn off all logging (including debug)
if config.logger == nil {
config.logger = LevelLogger{NoopLogger{}, false}
}