Skip to content

Commit

Permalink
rename compress to compression
Browse files Browse the repository at this point in the history
  • Loading branch information
Defined2014 committed Mar 14, 2024
1 parent 519d7cd commit 01abb8f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions zap_log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -280,7 +280,7 @@ func TestCompressError(t *testing.T) {
File: FileLogConfig{
Filename: tempDir + "/test.log",
MaxSize: 1,
Compress: "xxx",
Compression: "xxx",
},
}
_, _, err := InitLogger(conf)
Expand Down

0 comments on commit 01abb8f

Please sign in to comment.