diff --git a/config.go b/config.go index 8ce54aa..e78ac1b 100644 --- a/config.go +++ b/config.go @@ -35,9 +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 function for rotated files. + // Compression function for rotated files. // Currently only `gzip` and empty are supported, empty means compression disabled. - Compress string `toml:"compress" json:"compress"` + Compression string `toml:"compression" json:"compression"` } // Config serializes log related config in toml/json. diff --git a/log.go b/log.go index 8713b40..73f24a8 100644 --- a/log.go +++ b/log.go @@ -183,13 +183,13 @@ func initFileLog(cfg *FileLogConfig) (*lumberjack.Logger, error) { } compress := false - switch cfg.Compress { + switch cfg.Compression { case "": compress = false case "gzip": compress = true default: - return nil, fmt.Errorf("can't set compress to `%s`", cfg.Compress) + return nil, fmt.Errorf("can't set compression to `%s`", cfg.Compression) } // use lumberjack to logrotate diff --git a/zap_log_test.go b/zap_log_test.go index 153141d..262c87f 100644 --- a/zap_log_test.go +++ b/zap_log_test.go @@ -240,9 +240,9 @@ func TestRotateLogWithCompress(t *testing.T) { conf := &Config{ Level: "info", File: FileLogConfig{ - Filename: tempDir + "/test.log", - MaxSize: 1, - Compress: "gzip", + Filename: tempDir + "/test.log", + MaxSize: 1, + Compression: "gzip", }, } logger, _, err := InitLogger(conf) @@ -280,7 +280,7 @@ func TestCompressError(t *testing.T) { File: FileLogConfig{ Filename: tempDir + "/test.log", MaxSize: 1, - Compress: "xxx", + Compression: "xxx", }, } _, _, err := InitLogger(conf)