pub fn append(path: &Path, bark: &Bark, max_bytes: u64) -> Result<(), BarkError>Expand description
Appends bark to path, evicting oldest-first to keep the file under
max_bytes.
Eviction is oldest-out by whole lines: the file is rewritten with a
prefix of its lines dropped, atomically, so a reader never sees a
truncated one. A single record larger than max_bytes is written
anyway and leaves the file over the cap — the alternative is silently
dropping the alert that was too interesting to fit.
Serialized against other appenders — in this process or any other — by
an advisory lock on a sibling <path>.lock, held across the whole
read-modify-rename. Two writers without it lose each other’s records
outright; see this module’s own doc. Concurrent reads are not
blocked and do not need to be: the ring is only ever replaced whole,
by rename.
§Errors
BarkError::Io— the file could not be read, written, or replaced, or the lock beside it could not be taken.BarkError::Encode— the record could not be serialized.