forked from mailgun/log
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathudplog_test.go
35 lines (26 loc) · 935 Bytes
/
udplog_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package log
import (
"strings"
. "gopkg.in/check.v1"
)
type UDPLoggerSuite struct {
}
var _ = Suite(&UDPLoggerSuite{})
func (s *UDPLoggerSuite) TestNewUDPLogger(c *C) {
l, err := NewUDPLogger(Config{UDPLog, "info"})
c.Assert(err, IsNil)
c.Assert(l, NotNil)
udplog := l.(*udpLogger)
c.Assert(udplog.sev, Equals, SeverityInfo)
c.Assert(udplog.w, NotNil)
}
func (s *UDPLoggerSuite) TestFormatMessage(c *C) {
l, _ := NewUDPLogger(Config{UDPLog, "info"})
udplog := l.(*udpLogger)
message := udplog.FormatMessage(SeverityInfo, &CallerInfo{"filename", "filepath", "funcname", 42}, "hello %s", "world")
c.Assert(strings.HasPrefix(message, DefaultCategory), Equals, true)
c.Assert(strings.Contains(message, "filepath"), Equals, true)
c.Assert(strings.Contains(message, "funcname"), Equals, true)
c.Assert(strings.Contains(message, "42"), Equals, true)
c.Assert(strings.Contains(message, "hello world"), Equals, true)
}