2014-09-13 04:40:09 +04:00
|
|
|
package logrus_papertrail
|
|
|
|
|
|
|
|
import (
|
2014-09-14 00:53:20 +04:00
|
|
|
"fmt"
|
2014-09-13 04:40:09 +04:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/Sirupsen/logrus"
|
2014-09-14 00:53:20 +04:00
|
|
|
"github.com/stvp/go-udp-testing"
|
2014-09-13 04:40:09 +04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestWritingToUDP(t *testing.T) {
|
|
|
|
port := 16661
|
2014-09-14 00:53:20 +04:00
|
|
|
udp.SetAddr(fmt.Sprintf(":%d", port))
|
2014-09-13 04:40:09 +04:00
|
|
|
|
|
|
|
hook, err := NewPapertrailHook("localhost", port, "test")
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Unable to connect to local UDP server.")
|
|
|
|
}
|
|
|
|
|
2014-09-14 00:53:20 +04:00
|
|
|
log := logrus.New()
|
2014-09-13 04:40:09 +04:00
|
|
|
log.Hooks.Add(hook)
|
|
|
|
|
2014-09-14 00:53:20 +04:00
|
|
|
udp.ShouldReceive(t, "foo", func() {
|
|
|
|
log.Info("foo")
|
|
|
|
})
|
2014-09-13 04:40:09 +04:00
|
|
|
}
|