-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglog_test.go
47 lines (42 loc) · 1.14 KB
/
glog_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
package glog
import (
"sync"
"testing"
)
func TestNew(t *testing.T) {
/* default 100,10 (the logfile file size 100MB, total split 10 times)*/
var logger = New("testA.log", "[Info] ", Ldate | Ltime | Lshortfile)
logger.Println("Hello!")
logger.SetPrefix("[ChanePrefix]")
logger.Println("Glog!")
var Wg sync.WaitGroup
for i := 0; i < 10; i++ {
Wg.Add(1)
go func(count int){
for i := 0; i < count; i++ {
logger.Printf("%s-%d", "abcdefghijklmnopqrstuvwxyz", 123456789)
logger.Println("abcdefghijklmnopqrstuvwxyz0123456789你好,我是测试日志~!@#$%^&*()_+{}|:")
}
Wg.Done()
}(100000)
}
Wg.Wait()
}
func TestNewEx(t *testing.T) {
var logger = NewEx("testB.log", "[Info] ", Ldate | Ltime | Lshortfile, 10, 5)
logger.Println("Hello!")
logger.SetPrefix("[ChanePrefix]")
logger.Println("Glog!")
var Wg sync.WaitGroup
for i := 0; i < 10; i++ {
Wg.Add(1)
go func(count int){
for i := 0; i < count; i++ {
logger.Printf("%s-%d", "abcdefghijklmnopqrstuvwxyz", 123456789)
logger.Println("abcdefghijklmnopqrstuvwxyz0123456789你好,我是测试日志~!@#$%^&*()_+{}|:")
}
Wg.Done()
}(10000)
}
Wg.Wait()
}