pgterminate/notifier/notifier.go

25 lines
708 B
Go
Raw Permalink Normal View History

2018-06-10 08:44:53 +02:00
package notifier
import (
"github.com/jouir/pgterminate/base"
)
// Notifier generic interface for implementing a notifier
type Notifier interface {
Run()
Reload()
}
2018-06-24 16:39:36 +02:00
// NewNotifier looks into Config to create a Console, File or Syslog notifier and pass it
2018-06-10 08:44:53 +02:00
// the session channel for consuming sessions structs sent by terminator
func NewNotifier(ctx *base.Context) Notifier {
2018-06-24 16:39:36 +02:00
switch ctx.Config.LogDestination {
case "file":
2019-02-16 11:47:30 +01:00
return NewFile(ctx.Config.LogFile, ctx.Config.LogFormat, ctx.Sessions)
2018-06-24 16:39:36 +02:00
case "syslog":
2019-02-16 11:47:30 +01:00
return NewSyslog(ctx.Config.SyslogFacility, ctx.Config.SyslogIdent, ctx.Config.LogFormat, ctx.Sessions)
2018-06-24 16:39:36 +02:00
default: // console
2019-02-16 11:47:30 +01:00
return NewConsole(ctx.Config.LogFormat, ctx.Sessions)
2018-06-24 16:10:26 +02:00
}
2018-06-10 08:44:53 +02:00
}