-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathconsole_test.go
81 lines (65 loc) · 1.97 KB
/
console_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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package go_logger
import (
"testing"
"time"
)
func TestNewAdapterConsole(t *testing.T) {
NewAdapterConsole()
}
func TestAdapterConsole_Init(t *testing.T) {
consoleAdapter := NewAdapterConsole()
consoleConfig := &ConsoleConfig{}
consoleAdapter.Init(consoleConfig)
}
func TestAdapterConsole_Name(t *testing.T) {
consoleAdapter := NewAdapterConsole()
if consoleAdapter.Name() != CONSOLE_ADAPTER_NAME {
t.Error("consoleAdapter name error")
}
}
func TestAdapterConsole_WriteColor(t *testing.T) {
consoleAdapter := NewAdapterConsole()
consoleConfig := &ConsoleConfig{
Color: true,
}
consoleAdapter.Init(consoleConfig)
loggerMsg := &loggerMessage{
Timestamp: time.Now().Unix(),
TimestampFormat: time.Now().Format("2006-01-02 15:04:05"),
Millisecond: time.Now().UnixNano() / 1e6,
MillisecondFormat: time.Now().Format("2006-01-02 15:04:05.999"),
Level: LOGGER_LEVEL_DEBUG,
LevelString: "debug",
Body: "logger console adapter test color",
File: "console_test.go",
Line: 50,
Function: "TestAdapterConsole_WriteIsColor",
}
err := consoleAdapter.Write(loggerMsg)
if err != nil {
t.Error(err.Error())
}
}
func TestAdapterConsole_WriteJsonFormat(t *testing.T) {
consoleAdapter := NewAdapterConsole()
consoleConfig := &ConsoleConfig{
JsonFormat: true,
}
consoleAdapter.Init(consoleConfig)
loggerMsg := &loggerMessage{
Timestamp: time.Now().Unix(),
TimestampFormat: time.Now().Format("2006-01-02 15:04:05"),
Millisecond: time.Now().UnixNano() / 1e6,
MillisecondFormat: time.Now().Format("2006-01-02 15:04:05.999"),
Level: LOGGER_LEVEL_DEBUG,
LevelString: "debug",
Body: "logger console adapter test jsonFormat",
File: "console_test.go",
Line: 77,
Function: "TestAdapterConsole_WriteJsonFormat",
}
err := consoleAdapter.Write(loggerMsg)
if err != nil {
t.Error(err.Error())
}
}