levels: add string helper

This commit is contained in:
Simon Eskildsen
2014-07-26 21:02:08 -04:00
parent 6be56e6e50
commit cd8fc638cc
3 changed files with 30 additions and 0 deletions
+20
View File
@@ -10,6 +10,26 @@ type Fields map[string]interface{}
// Level type
type Level uint8
// Convert the Level to a string. E.g. PanicLevel becomes "panic".
func (level Level) String() string {
switch level {
case DebugLevel:
return "debug"
case InfoLevel:
return "info"
case WarnLevel:
return "warning"
case ErrorLevel:
return "error"
case FatalLevel:
return "fatal"
case PanicLevel:
return "panic"
}
return "unknown"
}
// These are the different logging levels. You can set the logging level to log
// on your instance of logger, obtained with `logrus.New()`.
const (