-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathwriter_test.go
57 lines (46 loc) · 1.16 KB
/
writer_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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2014 Canonical Ltd.
// Licensed under the LGPLv3, see LICENCE file for details.
package loggo
import (
"bytes"
"time"
gc "gopkg.in/check.v1"
)
type SimpleWriterSuite struct{}
var _ = gc.Suite(&SimpleWriterSuite{})
func (s *SimpleWriterSuite) TestNewSimpleWriter(c *gc.C) {
now := time.Now()
formatter := func(entry Entry) string {
return "<< " + entry.Message + " >>"
}
buf := &bytes.Buffer{}
writer := NewSimpleWriter(buf, formatter)
writer.Write(Entry{
Level: INFO,
Module: "test",
Filename: "somefile.go",
Line: 12,
Timestamp: now,
Message: "a message",
Labels: nil,
})
c.Check(buf.String(), gc.Equals, "<< a message >>\n")
}
func (s *SimpleWriterSuite) TestNewSimpleWriterWithLabels(c *gc.C) {
now := time.Now()
formatter := func(entry Entry) string {
return "<< " + entry.Message + " >>"
}
buf := &bytes.Buffer{}
writer := NewSimpleWriter(buf, formatter)
writer.Write(Entry{
Level: INFO,
Module: "test",
Filename: "somefile.go",
Line: 12,
Timestamp: now,
Message: "a message",
Labels: Labels{LoggerTags: "ONE,TWO"},
})
c.Check(buf.String(), gc.Equals, "<< a message >>\n")
}