Make ParseLevel case-insensitive

Coming from an environment where loglevels are always specified in
uppercase, having ParseLevel be case-insensitive is a nice to have.
This commit is contained in:
Rickard Dybeck
2016-02-16 16:27:38 +01:00
parent 3455d89ac9
commit 03ba213b8a
2 changed files with 30 additions and 1 deletions
+2 -1
View File
@@ -3,6 +3,7 @@ package logrus
import (
"fmt"
"log"
"strings"
)
// Fields type, used to pass to `WithFields`.
@@ -33,7 +34,7 @@ func (level Level) String() string {
// ParseLevel takes a string level and returns the Logrus log level constant.
func ParseLevel(lvl string) (Level, error) {
switch lvl {
switch strings.ToLower(lvl) {
case "panic":
return PanicLevel, nil
case "fatal":