dogger
1package level2
3type Level int4
5const (6TRACE Level = iota7DEBUG
8INFO
9WARN
10ERROR
11)
12
13var levelsString = map[Level]string{14TRACE: "trace",15DEBUG: "debug",16INFO: "info",17WARN: "warn",18ERROR: "error",19}
20
21var stringLevels = map[string]Level{22"trace": TRACE,23"debug": DEBUG,24"info": INFO,25"warn": WARN,26"error": ERROR,27}
28
29func (l Level) String() string {30level, exists := levelsString[l]31if !exists {32return levelsString[INFO]33}34
35return level36}
37
38func LogLevelFromString(level string) Level {39str, exists := stringLevels[level]40if !exists {41return stringLevels["info"]42}43
44return str45}
46