Skip to content

log: support d (day) unit in roll_interval log rotation directive#7889

Open
mohammed90 wants to merge 3 commits into
masterfrom
fix-logroll-d
Open

log: support d (day) unit in roll_interval log rotation directive#7889
mohammed90 wants to merge 3 commits into
masterfrom
fix-logroll-d

Conversation

@mohammed90

Copy link
Copy Markdown
Member

Originally fixed in #7865

roll_interval was using time.ParseDuration which doesn't understand the d (day) unit, causing roll_interval 1d to fail at startup despite Caddy's duration conventions supporting it.

Changes

  • FileWriter.RollInterval: Changed from time.Duration to caddy.Duration — also fixes JSON config support for the d unit
  • UnmarshalCaddyfile: Use caddy.ParseDuration instead of time.ParseDuration for roll_interval parsing
  • OpenWriter: Cast caddy.Durationtime.Duration when passing to timberjack's RotationInterval
  • Tests: Added TestCaddyfile_RollInterval covering 1d, 24h, 30m, 1.5d, and invalid input
log {
    output file /var/log/caddy/access.log {
        roll_interval 1d   # previously failed; now works
    }
}

Assistance Disclosure

Code generated by GitHub Copilot coding agent (claude-sonnet-4.6), reviewed and verified by the operator.

@mohammed90
mohammed90 requested a review from francislavoie July 16, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants