Bound worker log retention (#476)

Keep at most five rotated worker log files for up to fourteen days and
compress them. Retain the existing 100 MB rotation threshold so long-running
workers do not accumulate an unlimited number of log backups.

Co-authored-by: kroo-oai <kroo@openai.com>
This commit is contained in:
Yibo Zhuang
2026-09-01 21:34:14 +01:00
committed by GitHub
co-authored by kroo-oai
parent 28c0dd37b4
commit c42244f7e6
+11 -2
View File
@@ -261,6 +261,12 @@ func readBootstrapToken() (string, error) {
}
func createLogger() (*zap.Logger, error) {
const (
maxLogSizeMB = 100
maxLogBackups = 5
maxLogAgeDays = 14
)
level := zap.InfoLevel
if debug {
level = zap.DebugLevel
@@ -274,8 +280,11 @@ func createLogger() (*zap.Logger, error) {
}
logFileWriter := zapcore.AddSync(&lumberjack.Logger{
Filename: logFilePath,
MaxSize: 100, // megabytes
Filename: logFilePath,
MaxSize: maxLogSizeMB,
MaxBackups: maxLogBackups,
MaxAge: maxLogAgeDays,
Compress: true,
})
core := zapcore.NewCore(
zapcore.NewJSONEncoder(zap.NewProductionEncoderConfig()),