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

View file

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