MCPcopy
hub / github.com/sirupsen/logrus / ParseLevel

Function ParseLevel

logrus.go:27–47  ·  view source on GitHub ↗

ParseLevel takes a string level and returns the Logrus log level constant.

(lvl string)

Source from the content-addressed store, hash-verified

25
26// ParseLevel takes a string level and returns the Logrus log level constant.
27func 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.
50func (level *Level) UnmarshalText(text []byte) error {

Callers 2

UnmarshalTextMethod · 0.85
TestParseLevelFunction · 0.85

Calls 1

ErrorfMethod · 0.65

Tested by 1

TestParseLevelFunction · 0.68