Skip to content

Commit

Permalink
add log_level support temporarily
Browse files Browse the repository at this point in the history
  • Loading branch information
Junlin Gao committed May 15, 2020
1 parent c449e2c commit 52fc3bd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions log/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/tron-us/go-common/v2/env"

"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)

var (
Expand All @@ -30,6 +31,14 @@ func init() {
cfg = zap.NewProductionConfig()
}

if _, val := env.GetEnv("LOG_LEVEL"); val != "" {
var level zapcore.Level
if err := level.Set(val); err != nil {
//not support log_level, continue to next code
} else {
cfg.Level = zap.NewAtomicLevelAt(level)
}
}
if env.LogFile != "" {
cfg.OutputPaths = append(cfg.OutputPaths, env.LogFile)
}
Expand Down

0 comments on commit 52fc3bd

Please sign in to comment.