Skip to content

Commit

Permalink
(feat) add StringToLevel
Browse files Browse the repository at this point in the history
  • Loading branch information
adwpc committed Jul 25, 2021
1 parent fc6801b commit 91d87d8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion log.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ func Errorf(format string, v ...interface{}) { defaultLogger.Errorf(format, v...
func Panicf(format string, v ...interface{}) { defaultLogger.Panicf(format, v...) }

func Init(level string) {
defaultLogger.SetLevel(logrus.Level(StringToLevel(level)))
}

func StringToLevel(level string) Level {
l := logrus.DebugLevel
switch level {
case "trace":
Expand All @@ -83,7 +87,7 @@ func Init(level string) {
case "error":
l = logrus.ErrorLevel
}
defaultLogger.SetLevel(l)
return Level(l)
}

type MyLogger struct {
Expand Down

0 comments on commit 91d87d8

Please sign in to comment.