-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_test.go
62 lines (55 loc) · 1.16 KB
/
config_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
package log4go
import (
"testing"
"time"
)
var (
logConfig = `{
"level": "info",
"full_path": true,
"debug": true,
"file_writer": {
"level": "warn",
"filename": "./test/log4go-test-%Y%M%D.log",
"enable": true
},
"console_writer": {
"level": "error",
"enable": true,
"color": true,
"full_color": true
},
"kafka_writer": {
"level": "ERROR",
"enable": false,
"buffer_size": 10,
"debug": true,
"msg": {
"server_ip": "127.0.0.1"
},
"specify_version":true,
"version":"0.10.0.1",
"key": "kafka-test",
"producer_topic": "log4go-kafka-test",
"producer_return_successes": true,
"producer_timeout": 1,
"brokers": ["47.94.201.80:9092"]
}
}
`
)
func TestConfig(t *testing.T) {
if err := SetLog([]byte(logConfig)); err != nil {
panic(err)
}
var name = "log4go config test"
Debug("log4go by %s debug", name)
Info("log4go by %s info", name)
Notice("log4go by %s notice", name)
Warn("log4go by %s warn", name)
Error("log4go by %s error", name)
Critical("log4go by %s critical", name)
Alert("log4go by %s alert", name)
Emergency("log4go by %s emergency", name)
time.Sleep(1 * time.Second)
}