add log rotation config

This commit is contained in:
ginuerzh
2022-10-20 15:32:27 +08:00
parent bd7da26c42
commit 15d0a33716
3 changed files with 44 additions and 4 deletions

View File

@ -43,9 +43,33 @@ func SetGlobal(c *Config) {
}
type LogConfig struct {
Output string `yaml:",omitempty" json:"output,omitempty"`
Level string `yaml:",omitempty" json:"level,omitempty"`
Format string `yaml:",omitempty" json:"format,omitempty"`
Output string `yaml:",omitempty" json:"output,omitempty"`
Level string `yaml:",omitempty" json:"level,omitempty"`
Format string `yaml:",omitempty" json:"format,omitempty"`
Rotation *LogRotationConfig `yaml:",omitempty" json:"rotation,omitempty"`
}
type LogRotationConfig struct {
// MaxSize is the maximum size in megabytes of the log file before it gets
// rotated. It defaults to 100 megabytes.
MaxSize int `yaml:"maxSize,omitempty" json:"maxSize,omitempty"`
// MaxAge is the maximum number of days to retain old log files based on the
// timestamp encoded in their filename. Note that a day is defined as 24
// hours and may not exactly correspond to calendar days due to daylight
// savings, leap seconds, etc. The default is not to remove old log files
// based on age.
MaxAge int `yaml:"maxAge,omitempty" json:"maxAge,omitempty"`
// MaxBackups is the maximum number of old log files to retain. The default
// is to retain all old log files (though MaxAge may still cause them to get
// deleted.)
MaxBackups int `yaml:"maxBackups,omitempty" json:"maxBackups,omitempty"`
// LocalTime determines if the time used for formatting the timestamps in
// backup files is the computer's local time. The default is to use UTC
// time.
LocalTime bool `yaml:"localTime,omitempty" json:"localTime,omitempty"`
// Compress determines if the rotated log files should be compressed
// using gzip. The default is not to perform compression.
Compress bool `yaml:"compress,omitempty" json:"compress,omitempty"`
}
type ProfilingConfig struct {