core: Add support for d duration unit (#3323)

* caddy: Add support for `d` duration unit

* Improvements to ParseDuration; add unit tests

Co-authored-by: Matthew Holt <mholt@users.noreply.github.com>
This commit is contained in:
Francis Lavoie
2020-05-11 18:41:11 -04:00
committed by GitHub
parent 35e1d92d58
commit ef6e53bb5f
7 changed files with 167 additions and 18 deletions

View File

@ -489,3 +489,53 @@ func TestGlobalOptions(t *testing.T) {
}
}`)
}
func TestLogRollDays(t *testing.T) {
caddytest.AssertAdapt(t, `
:80
log {
output file /var/log/access.log {
roll_size 1gb
roll_keep 5
roll_keep_for 90d
}
}
`, "caddyfile", `{
"logging": {
"logs": {
"default": {
"exclude": [
"http.log.access.log0"
]
},
"log0": {
"writer": {
"filename": "/var/log/access.log",
"output": "file",
"roll_keep": 5,
"roll_keep_days": 90,
"roll_size_mb": 954
},
"include": [
"http.log.access.log0"
]
}
}
},
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [
":80"
],
"logs": {
"default_logger_name": "log0"
}
}
}
}
}
}`)
}