@marcel91200 / caddy Mirror · read-only / commits / 249adc1c
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 00:15 UTC

logging: Support turning off roll compression via Caddyfile (#4505)

Francis Lavoie committed Jan 4, 2022 at 14:11 UTC 249adc1c872ae46e640cfb7c330e332229d8d32a
2 files changed +13
caddytest/integration/caddyfile_adapt/log_roll_days.txt
+2
@@ -3,6 +3,7 @@
3 log {
4 output file /var/log/access.log {
5 roll_size 1gb
6 + roll_uncompressed
7 roll_keep 5
8 roll_keep_for 90d
9 }
@@ -20,6 +21,7 @@ log {
21 "writer": {
22 "filename": "/var/log/access.log",
23 "output": "file",
24 + "roll_gzip": false,
25 "roll_keep": 5,
26 "roll_keep_days": 90,
27 "roll_size_mb": 954
modules/logging/filewriter.go
+11
@@ -134,6 +134,7 @@ func (fw FileWriter) OpenWriter() (io.WriteCloser, error) {
134 // file <filename> {
135 // roll_disabled
136 // roll_size <size>
137 +// roll_uncompressed
138 // roll_keep <num>
139 // roll_keep_for <days>
140 // }
@@ -141,6 +142,9 @@ func (fw FileWriter) OpenWriter() (io.WriteCloser, error) {
142 // The roll_size value has megabyte resolution.
143 // Fractional values are rounded up to the next whole megabyte (MiB).
144 //
145 +// By default, compression is enabled, but can be turned off by setting
146 +// the roll_uncompressed option.
147 +//
148 // The roll_keep_for duration has day resolution.
149 // Fractional values are rounded up to the next whole number of days.
150 //
@@ -177,6 +181,13 @@ func (fw *FileWriter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
181 }
182 fw.RollSizeMB = int(math.Ceil(float64(size) / humanize.MiByte))
183
184 + case "roll_uncompressed":
185 + var f bool
186 + fw.RollCompress = &f
187 + if d.NextArg() {
188 + return d.ArgErr()
189 + }
190 +
191 case "roll_keep":
192 var keepStr string
193 if !d.AllArgs(&keepStr) {