pgterminate/notifier/notifier.go
2019-02-16 11:56:20 +01:00

24 lines
708 B
Go

package notifier
import (
"github.com/jouir/pgterminate/base"
)
// Notifier generic interface for implementing a notifier
type Notifier interface {
Run()
Reload()
}
// NewNotifier looks into Config to create a Console, File or Syslog notifier and pass it
// the session channel for consuming sessions structs sent by terminator
func NewNotifier(ctx *base.Context) Notifier {
switch ctx.Config.LogDestination {
case "file":
return NewFile(ctx.Config.LogFile, ctx.Config.LogFormat, ctx.Sessions)
case "syslog":
return NewSyslog(ctx.Config.SyslogFacility, ctx.Config.SyslogIdent, ctx.Config.LogFormat, ctx.Sessions)
default: // console
return NewConsole(ctx.Config.LogFormat, ctx.Sessions)
}
}