添加过期移除

This commit is contained in:
Yun
2024-01-23 13:37:51 +08:00
parent 10ecbce64f
commit 60ad89f164
6 changed files with 68 additions and 7 deletions
+10 -1
View File
@@ -7,7 +7,8 @@ type loggerOption struct {
isGinLog bool
isGid bool
traceField string // trace字段
errorToInfo bool //
errorToInfo bool // 错误日志是否写入info日志
days int // 日志保存天数
}
func defaultOptions() loggerOption {
@@ -15,6 +16,7 @@ func defaultOptions() loggerOption {
format: "json",
dir: "./log",
traceField: "trace_id",
days: 7,
}
}
@@ -69,6 +71,13 @@ func SetGID() Option {
}
}
// 日志保存天数
func SetDays(days int) Option {
return func(o *loggerOption) {
o.days = days
}
}
// 文件切割规则
// 1.文件大小
// 2.时间A(年/月/日/时)