-
Notifications
You must be signed in to change notification settings - Fork 0
/
kuttilog_defaultlogger_test.go
61 lines (51 loc) · 1.25 KB
/
kuttilog_defaultlogger_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
58
59
60
61
package kuttilog
import (
"bytes"
"testing"
)
func TestDefaultlogger(t *testing.T) {
t.Log("Testing Default Logger...")
ResetLogger()
SetLogLevel(Info)
var buf bytes.Buffer
defaultLogger.log.SetOutput(&buf)
// Test Print
Print(Info, "Hello")
if buf.String() != "Hello\n" {
t.Errorf("\nDefault Logger Print error:\n Expected: %#v\n Got: %#v",
"Hello\n",
buf.String())
}
// Test Printf
buf.Reset()
Printf(Info, "%v", "Hello")
if buf.String() != "Hello\n" {
t.Errorf("\nDefault Logger Printf error:\n Expected: %#v\n Got: %#v",
"Hello\n",
buf.String())
}
// Test Println
buf.Reset()
Println(Info, "Hello")
if buf.String() != "Hello\n" {
t.Errorf("\nDefault Logger Println error:\n Expected: %#v\n Got: %#v",
"Hello\n",
buf.String())
}
// Debug output should not happen at Info level
buf.Reset()
Printf(Debug, "Hello %v", 42)
if buf.String() != "" {
t.Errorf("\nDefault Logger Print error:\n Expected: \"\"\n Got: %#v",
buf.String())
}
// Debug output should happen at Debug level
SetLogLevel(Debug)
buf.Reset()
Printf(Debug, "Hello %v", 42)
if buf.String() != "[DEBUG] Hello 42\n" {
t.Errorf("\nDefault Logger Print error:\n Expected: %#v\n Got: %#v",
"[DEBUG] Hello 42\n",
buf.String())
}
}