Skip to content

Conversation

aeris
Copy link

@aeris aeris commented Sep 6, 2025

Lumberjack is unmaintained since 2 years.
A fork exists, Timberjack to replace it with more features.

This PR migrate to Timberjack and add support newest features, specially RotateAt options to allow to rotate log file base on date.

Assistance Disclosure

No AI was used.

@CLAassistant
Copy link

CLAassistant commented Sep 6, 2025

CLA assistant check
All committers have signed the CLA.

@francislavoie
Copy link
Member

Oh, fantastic! I didn't get the memo that a fork was worked on, we were waiting for someone to pick up the mantle. Will review soon.

Comment on lines 107 to 108
// Roll log file at fix time
RollAt []string `json:"roll_at,omitempty`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand what the inputs are here. What are the values supposed to be? The godoc comment here should be fleshed out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answering my own question, it looks something like this in timberjack

RotateAt:         []string{"00:00", "12:00"}, // Also rotate at 00:00 and 12:00 each day

@@ -109,6 +120,9 @@ type FileWriter struct {

// How many days to keep rolled log files. Default: 90
RollKeepDays int `json:"roll_keep_days,omitempty"`

// Rotated file will have format <logfilename>-<format>-<criterion>.log
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should explain that the default from timberjack is:

// Optional. If unset or invalid, defaults to 2006-01-02T15-04-05.000 (with fallback warning)

Also mention that the <format> must be a Go time compatible format described here https://pkg.go.dev/time#pkg-constants

Comment on lines +104 to +108
// Roll log file at fix minutes
RollAtMinutes []int `json:"roll_at_minutes,omitempty"`

// Roll log file at fix time
RollAt []string `json:"roll_at,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These godoc comments should cover some of the caveats mentioned in the timberjack README https://github.com/DeRuina/timberjack#%EF%B8%8F-rotation-notes--warnings (and eventually also in the Caddy website docs)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also subtleties like using either of RollAt/RollAtMinutes will use a background goroutine to trigger rotation, whereas RollInterval triggers a check on each log write whether the interval has been crossed and causes a rotation at that point (no goroutine).

@francislavoie francislavoie changed the title Move to timberjack and add rotate-at methods logging: Switch from lumberjack to timberjack add time-rolling options Sep 7, 2025
@francislavoie francislavoie changed the title logging: Switch from lumberjack to timberjack add time-rolling options logging: Switch from lumberjack to timberjack, add time-rolling options Sep 7, 2025
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.

3 participants