* feat: logx support logs rotation based on size limitation. (#1652) implementation of #1652 Totally compatible with the old logx.LogConf. No effect if users do not change their options. * feat: logx support logs rotation based on size limitation. (#1652) implementation of #1652 Totally compatible with the old logx.LogConf. No effect if users do not change their options. * feat: logx support logs rotation based on size limitation. (#1652) implementation of #1652 Totally compatible with the old logx.LogConf. No effect if users do not change their options. * feat: logx support logs rotation based on size limitation. (#1652) implementation of #1652 Totally compatible with the old logx.LogConf. No effect if users do not change their options.
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
package logx
|
||||
|
||||
type LogRotationRuleType int
|
||||
|
||||
const (
|
||||
LogRotationRuleTypeDaily LogRotationRuleType = iota
|
||||
LogRotationRuleTypeSizeLimit
|
||||
)
|
||||
|
||||
// A LogConf is a logging config.
|
||||
type LogConf struct {
|
||||
ServiceName string `json:",optional"`
|
||||
@@ -11,4 +18,16 @@ type LogConf struct {
|
||||
Compress bool `json:",optional"`
|
||||
KeepDays int `json:",optional"`
|
||||
StackCooldownMillis int `json:",default=100"`
|
||||
// MaxBackups represents how many backup log files will be kept. 0 means all files will be kept forever.
|
||||
// Only take effect when RotationRuleType is `LogRotationRuleTypeSizeLimit`
|
||||
// NOTE: the level of option `KeepDays` will be higher. Even thougth `MaxBackups` sets 0, log files will
|
||||
// still be removed if the `KeepDays` limitation is reached.
|
||||
MaxBackups int `json:",default=0"`
|
||||
// MaxSize represents how much space the writing log file takes up. 0 means no limit. The unit is `MB`.
|
||||
// Only take effect when RotationRuleType is `LogRotationRuleTypeSizeLimit`
|
||||
MaxSize int `json:",default=0"`
|
||||
// RotationRuleType represents the type of log rotation rule. Default is DailyRotateRule.
|
||||
// 0: LogRotationRuleTypeDaily
|
||||
// 1: LogRotationRuleTypeSizeLimit
|
||||
RotationRuleType LogRotationRuleType `json:",default=0,options=[0,1]"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user