-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger_test.go
58 lines (43 loc) · 1.03 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
package remote_log_go
import (
"sync"
"testing"
"time"
)
func TestMany(t *testing.T) {
httpTransport := NewHttpTransport(Info, Warn, Error, Access)
consoleTransport := NewConsoleTransport(Debug)
log := NewLogger("go_app", 40, httpTransport, consoleTransport)
err := log.Init()
if err != nil {
t.Errorf("初始化错误:%v", err.Error())
}
var wait sync.WaitGroup
wait.Add(100)
workM(log, &wait)
wait.Wait()
t.Log("执行完成")
time.Sleep(time.Second * 20)
}
func workM(log *Logger, w *sync.WaitGroup) {
for i := 0; i < 100; i++ {
go func() {
defer w.Done()
for i := 0; i < 100; i++ {
log.Info("go应用消息测试")
}
}()
}
}
func TestOne(t *testing.T) {
httpTransport := NewHttpTransport(Info, Warn, Error, Access)
consoleTransport := NewConsoleTransport(Debug)
log := NewLogger("go_app", 40, httpTransport, consoleTransport)
err := log.Init()
if err != nil {
t.Errorf("初始化错误:%v", err.Error())
}
log.Info("go消息测试2")
log.Info("go消息测试3")
time.Sleep(time.Second * 5)
}