Manage log destination explicitly

This commit is contained in:
Julien Riou 2018-06-24 16:39:36 +02:00
parent 85207e0a77
commit 96ade1c1d7
No known key found for this signature in database
GPG key ID: BA3E15176E45E85D
4 changed files with 14 additions and 6 deletions

View file

@ -10,14 +10,15 @@ type Notifier interface {
Reload()
}
// NewNotifier looks into Config to create a File or Console notifier and pass it
// 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 {
if ctx.Config.LogFile != "" {
switch ctx.Config.LogDestination {
case "file":
return NewFile(ctx.Config.LogFile, ctx.Sessions)
}
if ctx.Config.SyslogFacility != "" {
case "syslog":
return NewSyslog(ctx.Config.SyslogFacility, ctx.Config.SyslogIdent, ctx.Sessions)
default: // console
return NewConsole(ctx.Sessions)
}
return NewConsole(ctx.Sessions)
}