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:
kingecg 2026-07-11 08:54:19 +08:00
parent cdea9d86ed
commit 36b2fe9f34
1 changed files with 5 additions and 0 deletions

View File

@ -232,6 +232,10 @@ func makeFileAppender(appenderConfig LogAppenderConfig) *LoggerAppender {
} else if ageInt, ok := appenderConfig.Options["maxAge"].(int64); ok {
maxAge = ageInt
}
maxCount := int(1)
if count, ok := appenderConfig.Options["maxCount"].(int); ok {
maxCount = count
}
var ret LoggerAppender = &FileAppender{
formatter: SelectFormatter(appenderConfig.Formatter),
@ -239,6 +243,7 @@ func makeFileAppender(appenderConfig LogAppenderConfig) *LoggerAppender {
EnableRolling: rollingEnabled,
MaxSize: maxSize,
MaxAge: maxAge,
MaxCount: maxCount,
}
ret.(*FileAppender).start()