OSDN Git Service

new repo
[bytom/vapor.git] / vendor / github.com / sirupsen / logrus / hooks / syslog / syslog_test.go
1 package syslog
2
3 import (
4         "log/syslog"
5         "testing"
6
7         "github.com/sirupsen/logrus"
8 )
9
10 func TestLocalhostAddAndPrint(t *testing.T) {
11         log := logrus.New()
12         hook, err := NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "")
13
14         if err != nil {
15                 t.Errorf("Unable to connect to local syslog.")
16         }
17
18         log.Hooks.Add(hook)
19
20         for _, level := range hook.Levels() {
21                 if len(log.Hooks[level]) != 1 {
22                         t.Errorf("SyslogHook was not added. The length of log.Hooks[%v]: %v", level, len(log.Hooks[level]))
23                 }
24         }
25
26         log.Info("Congratulations!")
27 }