-
Notifications
You must be signed in to change notification settings - Fork 3
/
logger_test.go
78 lines (72 loc) · 2 KB
/
logger_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
package logger
import (
//"fmt"
"testing"
"time"
)
func TestLoggerDefault(t *testing.T) {
//根据配置文件设置日志等级
for i := 0; i < 1; i++ {
Log("log start")
Debug("debug log")
Info("info log")
Warn("warn log")
Error("error log")
Fatal("fatal log")
Info("remote", " log")
Log("log log")
}
}
func TestLoggerRolling(t *testing.T) {
SetConsole(false)
SetLevel(DEBUG)
// JSON(true)
SetServiceName("aaaa")
//根据配置文件,设置日志路径,日志名,日志切割大小限制
RollingLogger("log", "a.log", 10, 1, MB)
logobj := NewLog("bbbbbbbbbbbbb", "get_user_info").Data(map[string]interface{}{
"msg_id": "4002",
"arm_code": "0102",
"park_code": 7100000001,
"vpl_number": "陕AD1234",
})
// logobj := new(LogObj)
for i := 0; i < 100000; i++ {
logobj.Log("rolling ", "log start")
logobj.Debug("rolling ", "debug log")
logobj.Info("rolling ", "info log")
logobj.Warn("rolling ", "warn log")
logobj.Error("rolling ", "error log")
logobj.Fatal("rolling ", "fatal log")
logobj.Log("rolling ", "fatal log")
time.Sleep(time.Microsecond * 10)
}
// logobj := new(LogObj).ID("aaaaaaaaaaa").Tag("login").JSON()
// for i := 0; i < 100000; i++ {
// time.Sleep(1 * time.Millisecond)
// go func() {
// logobj.Log("rolling ", "log start")
// logobj.Debug("rolling ", "debug log")
// logobj.Info("rolling ", "info log")
// logobj.Warn("rolling ", "warn log")
// logobj.Error("rolling ", "error log")
// logobj.Fatal("rolling ", "fatal log")
// logobj.Log("rolling ", "fatal log")
// }()
// }
}
func TestLoggerDaily(t *testing.T) {
SetConsole(true)
DailyLogger("log", "a.log")
//根据配置文件,设置日志路径,日志名,日志切割大小限制
for i := 0; i < 100000000; i++ {
Log("daily ", "log start")
Debug("daily ", "debug log")
Info("daily ", "info log")
Warn("daily ", "warn log")
Error("daily ", "error log")
Fatal("daily ", "fatal log")
Log("daily ", "log log")
time.Sleep(time.Microsecond * 10)
}
}