Skip to content

Commit 939c391

Browse files
committed
chore: change input to string
1 parent dc46f93 commit 939c391

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

logger.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@ import (
1212

1313
var Level = zapcore.InfoLevel
1414

15-
func SetLogLevel(level zapcore.Level) {
16-
Level = level
15+
func SetLogLevel(level string) error {
16+
l, err := zapcore.ParseLevel(level)
17+
if err != nil {
18+
return err
19+
}
20+
21+
Level = l
22+
23+
return nil
1724
}
1825

1926
func NewLogger() (*zap.Logger, error) {
2027
config := zap.NewProductionConfig()
21-
2228
config.Level = zap.NewAtomicLevelAt(Level)
2329
config.EncoderConfig.EncodeTime = zapcore.TimeEncoderOfLayout(time.RFC3339Nano)
2430
config.EncoderConfig.TimeKey = "time"

0 commit comments

Comments
 (0)