-
Notifications
You must be signed in to change notification settings - Fork 0
/
init_test.go
59 lines (55 loc) · 1019 Bytes
/
init_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
package gologger
import (
"fmt"
"log"
"os"
"testing"
"time"
)
func TestPrintln(t *testing.T) {
thread := 3
ch := make(chan interface{})
itempriceLogger := Get("itemprice")
go func() {
//1分钟停下
time.AfterFunc(2*time.Minute, func() {
ch <- nil
})
}()
for i := 0; i < thread; i++ {
go func(t int) {
for {
msg := fmt.Sprintf("thread %d say hello", t)
Println(msg)
itempriceLogger.Println(msg)
time.Sleep(20 * time.Millisecond)
}
}(i)
}
<-ch
Close("", "itemprice")
log.Println("end")
}
func TestMain(m *testing.M) {
New(LoggerConf{
FileDir: "./log",
FileName: "dr",
Prefix: "",
DateFormat: "200601021504",
})
New(LoggerConf{
FileDir: "./log",
FileName: "itemprice",
Prefix: "",
DateFormat: "200601021504",
Flag: log.Ldate | log.Ltime,
Hook: &Hook{
AfterSplit: func(filepath string) error {
log.Println("upload file", filepath)
return nil
},
},
}, "itemprice")
go StartMonitor()
os.Exit(m.Run())
}