From 62b0947a31ea4396e90345959bf5d1c7b6148162 Mon Sep 17 00:00:00 2001 From: gotoxu Date: Fri, 3 Mar 2023 14:33:01 +0800 Subject: [PATCH] add Compress option to FileLogConfig Signed-off-by: gotoxu --- config.go | 3 +++ log.go | 1 + 2 files changed, 4 insertions(+) diff --git a/config.go b/config.go index 0d262cd..e7e58a5 100644 --- a/config.go +++ b/config.go @@ -35,6 +35,9 @@ type FileLogConfig struct { MaxDays int `toml:"max-days" json:"max-days"` // Maximum number of old log files to retain. MaxBackups int `toml:"max-backups" json:"max-backups"` + // Compress determines if the rotated log files should be compressed + // using gzip. The default is not to perform compression. + Compress bool `toml:"compress" json:"compress"` } // Config serializes log related config in toml/json. diff --git a/log.go b/log.go index 040ec6d..ce7fd45 100644 --- a/log.go +++ b/log.go @@ -126,6 +126,7 @@ func initFileLog(cfg *FileLogConfig) (*lumberjack.Logger, error) { MaxBackups: cfg.MaxBackups, MaxAge: cfg.MaxDays, LocalTime: true, + Compress: cfg.Compress, }, nil }