Skip to content

Commit

Permalink
fix(lwlogger): do not override explicit level argument (#1084)
Browse files Browse the repository at this point in the history
  • Loading branch information
kolbeinn authored Dec 28, 2022
1 parent c5a04ea commit 452dff8
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lwlogger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ var (

// New initialize a new logger with the provided level and options
func New(level string, options ...zap.Option) *zap.Logger {
// give priority to the environment variable
if envLevel := LogLevelFromEnvironment(); envLevel != "" {
level = envLevel
if level == "" {
level = LogLevelFromEnvironment()
}

zapConfig := zap.Config{
Expand Down Expand Up @@ -81,9 +80,8 @@ func New(level string, options ...zap.Option) *zap.Logger {
// NewWithWriter initialize a new logger with the provided level and options
// but redirecting the logs to the provider io.Writer
func NewWithWriter(level string, out io.Writer, options ...zap.Option) *zap.Logger {
// give priority to the environment variable
if envLevel := LogLevelFromEnvironment(); envLevel != "" {
level = envLevel
if level == "" {
level = LogLevelFromEnvironment()
}

var (
Expand Down

0 comments on commit 452dff8

Please sign in to comment.