-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrotatelogs_test.go
42 lines (35 loc) · 1.04 KB
/
rotatelogs_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
package rotatelogs
import (
"testing"
"time"
)
func TestLog(t *testing.T) {
logs, err := NewRotateLogs("d:\\log", "20060102\\gamelog_20060102_150405.log", //) //WithRotateMaxSize(1024),
WithRotationTime(10*time.Second), WithChannelLen(10), WithMaxAge(50*time.Second))
if err != nil {
t.Fatal(err)
}
for i := 0; i < 1000000; i++ {
time.Sleep(200 * time.Millisecond)
for range 10 {
logs.Write([]byte("111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"))
}
}
logs.Sync()
logs.Close()
}
func TestLog2(t *testing.T) {
logs, err := NewRotateLogs("d:\\log", "20060102\\gamelog_20060102_150405.log", //) //WithRotateMaxSize(1024),
WithRotationTime(10*time.Second), WithChannelLen(10), WithMaxFileNum(4))
if err != nil {
t.Fatal(err)
}
for i := 0; i < 1000000; i++ {
time.Sleep(200 * time.Millisecond)
for range 10 {
logs.Write([]byte("111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"))
}
}
logs.Sync()
logs.Close()
}