ParseLevel takes a string level and returns the Logrus log level constant.
(lvl string)
| 25 | |
| 26 | // ParseLevel takes a string level and returns the Logrus log level constant. |
| 27 | func ParseLevel(lvl string) (Level, error) { |
| 28 | switch strings.ToLower(lvl) { |
| 29 | case "panic": |
| 30 | return PanicLevel, nil |
| 31 | case "fatal": |
| 32 | return FatalLevel, nil |
| 33 | case "error": |
| 34 | return ErrorLevel, nil |
| 35 | case "warn", "warning": |
| 36 | return WarnLevel, nil |
| 37 | case "info": |
| 38 | return InfoLevel, nil |
| 39 | case "debug": |
| 40 | return DebugLevel, nil |
| 41 | case "trace": |
| 42 | return TraceLevel, nil |
| 43 | } |
| 44 | |
| 45 | var l Level |
| 46 | return l, fmt.Errorf("not a valid logrus Level: %q", lvl) |
| 47 | } |
| 48 | |
| 49 | // UnmarshalText implements encoding.TextUnmarshaler. |
| 50 | func (level *Level) UnmarshalText(text []byte) error { |