LeviLamina
Loading...
Searching...
No Matches
ll::io::RotatePolicy Class Reference

#include <RotatePolicy.h>

Inheritance diagram for ll::io::RotatePolicy:

Public Member Functions

 RotatePolicy (RotateConfig const &config)

Static Public Member Functions

static LLNDAPI std::string defaultNamer (ArchiveNameInfo const &info)
static LLNDAPI RotatePolicy disabled ()
 A policy that never rotates.

Public Attributes

std::function< std::string(ArchiveNameInfo const &)> namer {&defaultNamer}
bool rotateOnOpen = true
uint64 maxFileSize = 32ull * 1024 * 1024
RotateInterval interval = RotateInterval::Daily
bool compress = true
 Compresses archives to gzip on a background thread. The active file is never compressed.
size_t keepUncompressed = 7
bool cleanup = true
 Deletes archives that fall outside the limits below. When false, nothing is ever removed.
size_t maxFiles = 1024
 Keeps at most this many archives, counting compressed and plain alike. 0 disables the limit.
int maxAgeDays = 120
 Removes archives last modified more than this many days ago. 0 disables the limit.
uint64 totalSizeCap = 512ull * 1024 * 1024

Detailed Description

Describes when a log file is rotated and what happens to the archives afterwards.

Note
The settings fall into three groups that are evaluated at different times: once when the file is opened, before every message is written, and asynchronously after an archive is created.

Member Function Documentation

◆ defaultNamer()

LLNDAPI std::string ll::io::RotatePolicy::defaultNamer ( ArchiveNameInfo const & info)
static

The default middle section, 2026-09-19, plus .1, .2 and so on for later rotations within the same interval. Hourly rotation adds the hour.

Member Data Documentation

◆ namer

std::function<std::string(ArchiveNameInfo const&)> ll::io::RotatePolicy::namer {&defaultNamer}

Spells an archive's name, to which the active file's extension is appended, so a file rotated on that date archives as 2026-09-19.log.

Note
A custom scheme has to start with a four digit year, otherwise compression and retention will not recognize its own output.

◆ rotateOnOpen

bool ll::io::RotateConfig::rotateOnOpen = true
inherited

Archives an existing, non-empty file when the sink opens it, so each run owns its own file instead of appending to the previous run's output.

◆ maxFileSize

uint64 ll::io::RotateConfig::maxFileSize = 32ull * 1024 * 1024
inherited

Rotates once writing the next message would grow the file past this many bytes. 0 disables the size trigger.

Note
A single message is never split across files, so one oversized message produces one oversized file.

◆ interval

RotateInterval ll::io::RotateConfig::interval = RotateInterval::Daily
inherited

Rotates when the message's timestamp crosses this boundary. Evaluated against the time the message was created rather than the time it reaches the file.

◆ keepUncompressed

size_t ll::io::RotateConfig::keepUncompressed = 7
inherited

Leaves this many of the newest archives uncompressed, so recently rotated output stays greppable without unpacking it first.

◆ totalSizeCap

uint64 ll::io::RotateConfig::totalSizeCap = 512ull * 1024 * 1024
inherited

Removes the oldest archives until their total size on disk falls below this. 0 disables the limit.

Note
This counts compressed sizes, so the reachable history depends on compress.

The documentation for this class was generated from the following file: