-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwrite_test.go
59 lines (47 loc) · 1.15 KB
/
write_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 zapper
import (
"errors"
"fmt"
"path/filepath"
"testing"
"time"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
func TestNewWriter(t *testing.T) {
var filepath string = "/Users/yymt/Documents/zaper/test_cron_rotate.log"
syncCycle := time.Minute
wr := NewWriter(filepath, syncCycle, 1024)
syncer := zapcore.AddSync(wr) //ioutil.Discard
logger := NewAdvancedLogger(zap.DebugLevel, "product", "module", syncer)
SetDefaultLogger(logger)
syncLock := make(chan struct{}, 0)
go func() {
for i := 0; i <= 240; i++ {
err:=errors.New("text string001")
Error("test cron zaper ",
zap.Int("int", 10),
zap.Error(fmt.Errorf("text string: %w",err)),
zap.String("msg", "val string1"),
zap.String("msg", "val string2"),
zap.String("msg", "val string3"),
zap.Time("time", time.Now()),
)
time.Sleep(time.Second * 1)
}
time.Sleep(time.Second * 20)
Sync()
syncLock <- struct{}{}
}()
<-syncLock
}
func TestAbs(t *testing.T) {
s:="2021-10-09 15:00:00.log"
if !filepath.IsAbs(s){
f,e:=filepath.Abs(s)
println(f,e)
}
f:="/Users/yymt/Documents/zaper/zapper2021-11-08 17:00:00.log"
f2,e:=filepath.Abs(f)
t.Log(f2,e)
}