Made the notification level flag global for all notification types.

This commit is contained in:
Fabrizio Steiner 2018-03-02 13:08:40 +01:00
parent 4ac08dfb30
commit e1ead2f46f
5 changed files with 26 additions and 24 deletions

View file

@ -28,9 +28,10 @@ type emailTypeNotifier struct {
Port int
tlsSkipVerify bool
entries []*log.Entry
logLevels []log.Level
}
func newEmailNotifier(c *cli.Context) typeNotifier {
func newEmailNotifier(c *cli.Context, acceptedLogLevels []log.Level) typeNotifier {
n := &emailTypeNotifier{
From: c.GlobalString("notification-email-from"),
To: c.GlobalString("notification-email-to"),
@ -39,6 +40,7 @@ func newEmailNotifier(c *cli.Context) typeNotifier {
Password: c.GlobalString("notification-email-server-password"),
Port: c.GlobalInt("notification-email-server-port"),
tlsSkipVerify: c.GlobalBool("notification-email-server-tls-skip-verify"),
logLevels: acceptedLogLevels,
}
log.AddHook(n)
@ -112,14 +114,7 @@ func (e *emailTypeNotifier) SendNotification() {
}
func (e *emailTypeNotifier) Levels() []log.Level {
// TODO: Make this configurable.
return []log.Level{
log.PanicLevel,
log.FatalLevel,
log.ErrorLevel,
log.WarnLevel,
log.InfoLevel,
}
return e.logLevels
}
func (e *emailTypeNotifier) Fire(entry *log.Entry) error {