logrus/hooks/syslog/syslog_test.go

30 lines
566 B
Go
Raw Permalink Normal View History

// +build !windows,!nacl,!plan9
package syslog
2014-07-18 11:28:40 +04:00
import (
2014-07-28 09:01:56 +04:00
"log/syslog"
"testing"
"github.com/sirupsen/logrus"
2014-07-18 11:28:40 +04:00
)
func TestLocalhostAddAndPrint(t *testing.T) {
2014-07-28 09:01:56 +04:00
log := logrus.New()
hook, err := NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "")
2014-07-18 11:28:40 +04:00
if err != nil {
t.Errorf("Unable to connect to local syslog.")
}
log.Hooks.Add(hook)
for _, level := range hook.Levels() {
if len(log.Hooks[level]) != 1 {
t.Errorf("SyslogHook was not added. The length of log.Hooks[%v]: %v", level, len(log.Hooks[level]))
}
}
log.Info("Congratulations!")
2014-07-28 09:01:56 +04:00
}