github.com/godaddy-x/freego@v1.0.156/zlog/zlog_test.go (about) 1 package zlog_test 2 3 import ( 4 "errors" 5 "fmt" 6 "github.com/godaddy-x/freego/zlog" 7 "testing" 8 ) 9 10 func TestZap(t *testing.T) { 11 file := &zlog.FileConfig{ 12 Filename: "/Users/shadowsick/go/src/github.com/godaddy-x/spikeProxy1.zlog", // 日志文件路径 13 MaxSize: 1, // 每个日志文件保存的最大尺寸 单位:M 14 MaxBackups: 30, // 日志文件最多保存多少个备份 15 MaxAge: 7, // 文件最多保存多少天 16 Compress: true, // 是否压缩 17 } 18 config := &zlog.ZapConfig{ 19 Level: zlog.DEBUG, 20 Console: false, 21 FileConfig: file, 22 Callfunc: func(b []byte) error { 23 fmt.Println(string(b)) 24 return nil 25 }, 26 } 27 zlog.InitDefaultLog(config) 28 a := errors.New("my") 29 b := errors.New("ow") 30 c := []error{a, b} 31 zlog.Info("zlog 初始化成功", 0, zlog.String("test", "w"), zlog.Any("wo", map[string]interface{}{"yy": 45}), zlog.AddError(c...)) 32 zlog.Println("test") 33 34 }