```
feat(logger): add maxCount configuration option for file appender Add support for maxCount parameter in file appender configuration. The maxCount option allows users to specify the maximum number of backup files to keep when log rotation is enabled. The new configuration option defaults to 1 if not specified in the appender options and is passed to the FileAppender struct during initialization. ``` Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
parent
cdea9d86ed
commit
36b2fe9f34
5
file.go
5
file.go
|
|
@ -232,6 +232,10 @@ func makeFileAppender(appenderConfig LogAppenderConfig) *LoggerAppender {
|
||||||
} else if ageInt, ok := appenderConfig.Options["maxAge"].(int64); ok {
|
} else if ageInt, ok := appenderConfig.Options["maxAge"].(int64); ok {
|
||||||
maxAge = ageInt
|
maxAge = ageInt
|
||||||
}
|
}
|
||||||
|
maxCount := int(1)
|
||||||
|
if count, ok := appenderConfig.Options["maxCount"].(int); ok {
|
||||||
|
maxCount = count
|
||||||
|
}
|
||||||
|
|
||||||
var ret LoggerAppender = &FileAppender{
|
var ret LoggerAppender = &FileAppender{
|
||||||
formatter: SelectFormatter(appenderConfig.Formatter),
|
formatter: SelectFormatter(appenderConfig.Formatter),
|
||||||
|
|
@ -239,6 +243,7 @@ func makeFileAppender(appenderConfig LogAppenderConfig) *LoggerAppender {
|
||||||
EnableRolling: rollingEnabled,
|
EnableRolling: rollingEnabled,
|
||||||
MaxSize: maxSize,
|
MaxSize: maxSize,
|
||||||
MaxAge: maxAge,
|
MaxAge: maxAge,
|
||||||
|
MaxCount: maxCount,
|
||||||
}
|
}
|
||||||
|
|
||||||
ret.(*FileAppender).start()
|
ret.(*FileAppender).start()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue