From 36b2fe9f34d8f82dda560461a9efb9886d3be84d Mon Sep 17 00:00:00 2001 From: kingecg Date: Sat, 11 Jul 2026 08:54:19 +0800 Subject: [PATCH] ``` 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 --- file.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/file.go b/file.go index c45275b..0f74c64 100644 --- a/file.go +++ b/file.go @@ -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()