forked from tuya/tuya-pulsar-sdk-go
/
config.go
47 lines (39 loc) · 1.03 KB
/
config.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 tylog
import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
const (
FormatEnumJSON FormatEnum = "json"
FormatEnumConsole FormatEnum = "console"
DefaultRotatePeriodSecond int64 = 60 * 60 * 24 // 一天
)
var (
LevelEnumDebug = zap.NewAtomicLevelAt(zapcore.DebugLevel)
LevelEnumInfo = zap.NewAtomicLevelAt(zapcore.InfoLevel)
)
type LogConfig struct {
// 中国区使用true
localTime bool
// MultiWrite 如果为true,日志会同时写入文件和终端,默认为true
multiWrite bool
// 日志级别,默认为debug
level LevelEnum
// AppName 默认为tmp
appName string
// Dir 日志文件存放目录,默认为logs
dir string
// Format默认为console,方便调试
format FormatEnum
// hook
Hooks []LogHook
// 单个log文件最大size,默认为100M
maxSize int
// 日志按时间分割,默认为一天
rotatePeriodSecond int64
// max num of rotated backups, zero means infinite
maxBackups int
}
type LevelEnum = zap.AtomicLevel
type FormatEnum string
type FormatTime = zapcore.TimeEncoder