From 088ac1380dc4161565c4854359de7db63f21cfc1 Mon Sep 17 00:00:00 2001 From: Joern Barthel Date: Wed, 13 May 2015 14:12:36 +0200 Subject: [PATCH] Expose all levels (for hooks). --- hooks/syslog/syslog.go | 9 +-------- logrus.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/hooks/syslog/syslog.go b/hooks/syslog/syslog.go index c59f331..a36e200 100644 --- a/hooks/syslog/syslog.go +++ b/hooks/syslog/syslog.go @@ -50,12 +50,5 @@ func (hook *SyslogHook) Fire(entry *logrus.Entry) error { } func (hook *SyslogHook) Levels() []logrus.Level { - return []logrus.Level{ - logrus.PanicLevel, - logrus.FatalLevel, - logrus.ErrorLevel, - logrus.WarnLevel, - logrus.InfoLevel, - logrus.DebugLevel, - } + return logrus.AllLevels } diff --git a/logrus.go b/logrus.go index fa8a7cc..1e9670d 100644 --- a/logrus.go +++ b/logrus.go @@ -53,6 +53,16 @@ func ParseLevel(lvl string) (Level, error) { return l, fmt.Errorf("not a valid logrus Level: %q", lvl) } +// A constant exposing all logging levels +var AllLevels = []Level{ + PanicLevel, + FatalLevel, + ErrorLevel, + WarnLevel, + InfoLevel, + DebugLevel, +} + // These are the different logging levels. You can set the logging level to log // on your instance of logger, obtained with `logrus.New()`. const (