Skip to content

Commit

Permalink
logging: Support turning off roll compression via Caddyfile (#4505)
Browse files Browse the repository at this point in the history
  • Loading branch information
francislavoie authored Jan 4, 2022
1 parent e9dde23 commit 249adc1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions caddytest/integration/caddyfile_adapt/log_roll_days.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
log {
output file /var/log/access.log {
roll_size 1gb
roll_uncompressed
roll_keep 5
roll_keep_for 90d
}
Expand All @@ -20,6 +21,7 @@ log {
"writer": {
"filename": "/var/log/access.log",
"output": "file",
"roll_gzip": false,
"roll_keep": 5,
"roll_keep_days": 90,
"roll_size_mb": 954
Expand Down
11 changes: 11 additions & 0 deletions modules/logging/filewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,17 @@ func (fw FileWriter) OpenWriter() (io.WriteCloser, error) {
// file <filename> {
// roll_disabled
// roll_size <size>
// roll_uncompressed
// roll_keep <num>
// roll_keep_for <days>
// }
//
// The roll_size value has megabyte resolution.
// Fractional values are rounded up to the next whole megabyte (MiB).
//
// By default, compression is enabled, but can be turned off by setting
// the roll_uncompressed option.
//
// The roll_keep_for duration has day resolution.
// Fractional values are rounded up to the next whole number of days.
//
Expand Down Expand Up @@ -177,6 +181,13 @@ func (fw *FileWriter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
}
fw.RollSizeMB = int(math.Ceil(float64(size) / humanize.MiByte))

case "roll_uncompressed":
var f bool
fw.RollCompress = &f
if d.NextArg() {
return d.ArgErr()
}

case "roll_keep":
var keepStr string
if !d.AllArgs(&keepStr) {
Expand Down

0 comments on commit 249adc1

Please sign in to comment.