8 // Fields type, used to pass to `WithFields`.
9 type Fields map[string]interface{}
14 // Convert the Level to a string. E.g. PanicLevel becomes "panic".
15 func (level Level) String() string {
34 // ParseLevel takes a string level and returns the Logrus log level constant.
35 func ParseLevel(lvl string) (Level, error) {
38 return PanicLevel, nil
40 return FatalLevel, nil
42 return ErrorLevel, nil
43 case "warn", "warning":
48 return DebugLevel, nil
52 return l, fmt.Errorf("not a valid logrus Level: %q", lvl)
55 // These are the different logging levels. You can set the logging level to log
56 // on your instance of logger, obtained with `logrus.New()`.
58 // PanicLevel level, highest level of severity. Logs and then calls panic with the
59 // message passed to Debug, Info, ...
60 PanicLevel Level = iota
61 // FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the
62 // logging level is set to Panic.
64 // ErrorLevel level. Logs. Used for errors that should definitely be noted.
65 // Commonly used for hooks to send errors to an error tracking service.
67 // WarnLevel level. Non-critical entries that deserve eyes.
69 // InfoLevel level. General operational entries about what's going on inside the
72 // DebugLevel level. Usually only enabled when debugging. Very verbose logging.
76 // Won't compile if StdLogger can't be realized by a log.Logger
78 _ StdLogger = &log.Logger{}
79 _ StdLogger = &Entry{}
80 _ StdLogger = &Logger{}
83 // StdLogger is what your logrus-enabled library should take, that way
84 // it'll accept a stdlib logger and a logrus logger. There's no standard
85 // interface, this is the closest we get, unfortunately.
86 type StdLogger interface {
88 Printf(string, ...interface{})
89 Println(...interface{})
92 Fatalf(string, ...interface{})
93 Fatalln(...interface{})
96 Panicf(string, ...interface{})
97 Panicln(...interface{})