Add log-format option

This commit is contained in:
Julien Riou 2019-02-16 11:47:30 +01:00
commit 24eb4fe203
No known key found for this signature in database
GPG key ID: BA3E15176E45E85D
9 changed files with 61 additions and 44 deletions

View file

@ -7,12 +7,14 @@ import (
// Console notifier structure
type Console struct {
format string
sessions chan *base.Session
}
// NewConsole creates a console notifier
func NewConsole(sessions chan *base.Session) Notifier {
func NewConsole(format string, sessions chan *base.Session) Notifier {
return &Console{
format: format,
sessions: sessions,
}
}
@ -21,7 +23,7 @@ func NewConsole(sessions chan *base.Session) Notifier {
func (c *Console) Run() {
log.Info("Starting console notifier")
for session := range c.sessions {
log.Infof("%s\n", session)
log.Info(session.Format(c.format))
}
}