Documentation
¶
Overview ¶
Package logcap keeps the daemon's log file from growing without bound.
The daemon logs to stderr, and whoever started it decides where that goes: `caprock up` points it at <data_dir>/caprock.log, launchd and systemd at <data_dir>/service.log, a terminal at the terminal. Nothing ever trimmed either file. On the owner's machine caprock.log reached 4.6GB — 1.1M copies of one warning — before anyone looked.
When stderr is a regular file past Limit, it is renamed to <name>.1 (replacing the previous one) and a fresh file is opened and put in place of stdout and stderr, so the rest of the process keeps writing without knowing. Renaming rather than truncating does not depend on how the file was opened: launchd's descriptor may or may not append, and truncating a file someone writes to without O_APPEND leaves a hole the size of everything before.
Index ¶
Constants ¶
const ( // Limit is the size at which the log is rotated. One previous file is // kept, so the most a data dir ever holds is about twice this. Limit = 64 << 20 // Keep is how much of the end of an old log trimIdle leaves. Keep = 8 << 20 // Every is how often the size is checked. Every = 10 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.