MCPcopy
hub / github.com/sirupsen/logrus / TestLocalhostAddAndPrint

Function TestLocalhostAddAndPrint

hooks/syslog/syslog_test.go:12–29  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestLocalhostAddAndPrint(t *testing.T) {
13 log := logrus.New()
14 hook, err := NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "")
15
16 if err != nil {
17 t.Errorf("Unable to connect to local syslog.")
18 }
19
20 log.Hooks.Add(hook)
21
22 for _, level := range hook.Levels() {
23 if len(log.Hooks[level]) != 1 {
24 t.Errorf("SyslogHook was not added. The length of log.Hooks[%v]: %v", level, len(log.Hooks[level]))
25 }
26 }
27
28 log.Info("Congratulations!")
29}

Callers

nothing calls this directly

Calls 6

LevelsMethod · 0.95
NewFunction · 0.92
NewSyslogHookFunction · 0.85
AddMethod · 0.80
ErrorfMethod · 0.65
InfoMethod · 0.65

Tested by

no test coverage detected