Skip to content

Commit

Permalink
fix: wrong initialization of logger and fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
buraksezer committed Aug 15, 2021
1 parent 264bc4f commit 4ef29e6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
18 changes: 10 additions & 8 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion olric.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions pkg/flog/flog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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 {
Expand Down

0 comments on commit 4ef29e6

Please sign in to comment.