add level from string
This commit is contained in:
11
level.go
11
level.go
@@ -1,6 +1,7 @@
|
|||||||
package logb
|
package logb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -61,3 +62,13 @@ func (l Level) String() string {
|
|||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func LevelFromString(s string) Level {
|
||||||
|
s = strings.ToUpper(s)
|
||||||
|
for _, l := range []Level{ERROR, WARN, INFO, DEBUG, VERBOSE} {
|
||||||
|
if l.String() == s {
|
||||||
|
return l
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return INFO
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user