-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog_test.go
54 lines (50 loc) · 1019 Bytes
/
log_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
package golog
import (
"github.com/gin-gonic/gin"
uuid "github.com/satori/go.uuid"
"testing"
)
func TestConsole(t *testing.T) {
Init(&Config{FileConfig: &FileConfig{
LogFilePath: "./log/1",
MaxSize: 1,
MaxBackups: 1,
MaxAge: 1,
Console: true,
LevelString: "info",
ServiceName: "test",
}})
Info("string data")
}
func TestDebug(t *testing.T) {
Init(&Config{FileConfig: &FileConfig{
LogFilePath: "./log/2",
MaxSize: 1,
MaxBackups: 1,
MaxAge: 1,
LevelString: "debug",
ServiceName: "test",
}})
Info("debug data %s", "debug")
}
func TestDebugC(t *testing.T) {
Init(&Config{FileConfig: &FileConfig{
LogFilePath: "./log/2",
MaxSize: 1,
MaxBackups: 1,
MaxAge: 1,
LevelString: "debug",
ServiceName: "test",
}})
ctx := &gin.Context{
Request: nil,
Writer: nil,
Params: nil,
Keys: nil,
Errors: nil,
Accepted: nil,
}
traceID := uuid.NewV4().String()
ctx.Set(TraceIDKey, traceID)
InfoC(ctx, "debug data %s", "debug")
}