diff --git a/config/config.go b/config/config.go index b4abf936..eb6e604a 100644 --- a/config/config.go +++ b/config/config.go @@ -265,20 +265,22 @@ func (c *Config) Validate() error { // Sanitize sanitizes the given configuration. // It returns an error if there is something very bad in the configuration. func (c *Config) Sanitize() error { - if c.Logger == nil { - if c.LogOutput == nil { - c.LogOutput = os.Stderr - } - if c.LogLevel == "" { - c.LogLevel = DefaultLogLevel - } - c.Logger = log.New(c.LogOutput, "", log.LstdFlags) + if c.LogOutput == nil { + c.LogOutput = os.Stderr + } + + if c.LogLevel == "" { + c.LogLevel = DefaultLogLevel } if c.LogVerbosity <= 0 { c.LogVerbosity = DefaultLogVerbosity } + if c.Logger == nil { + c.Logger = log.New(c.LogOutput, "", log.LstdFlags) + } + if c.Hasher == nil { c.Hasher = hasher.NewDefaultHasher() } diff --git a/olric.go b/olric.go index bf425cd8..cd243e52 100644 --- a/olric.go +++ b/olric.go @@ -184,7 +184,7 @@ func New(c *config.Config) (*Olric, error) { filter := &logutils.LevelFilter{ Levels: []logutils.LogLevel{"DEBUG", "WARN", "ERROR", "INFO"}, MinLevel: logutils.LogLevel(strings.ToUpper(c.LogLevel)), - Writer: c.LogOutput, + Writer: c.Logger.Writer(), } c.Logger.SetOutput(filter) diff --git a/pkg/flog/flog.go b/pkg/flog/flog.go index e689d75b..b534d4c0 100644 --- a/pkg/flog/flog.go +++ b/pkg/flog/flog.go @@ -97,7 +97,7 @@ func (f *Logger) V(level int32) Verbose { } } -// Enabled will return true if this log level is enabled, guarded by the value of verbosity level. +// Ok will return true if this log level is enabled, guarded by the value of verbosity level. func (v Verbose) Ok() bool { return v.ok } @@ -116,7 +116,7 @@ func (v Verbose) Printf(format string, i ...interface{}) { } } -// Printf calls v.f.logger.Println to print to the logger. +// Println calls v.f.logger.Println to print to the logger. // Arguments are handled in the manner of fmt.Println. func (v Verbose) Println(i ...interface{}) { if !v.ok {