mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-09-29 19:41:15 +02:00
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:
@@ -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()),
|
||||
|
||||
Reference in New Issue
Block a user