Skip to main content

Module tail

Module tail 

Source
Expand description

Following a node’s log files as they are written and rotated.

ant-node rotates daily by filename (ant-node.YYYY-MM-DD.log) and prunes to --log-max-files, so “rotation” here is a new file appearing beside the old one rather than a cursor moving — which makes the tailer’s job mostly bookkeeping over a sorted file list.

Two behaviours are worth knowing about before reading the code:

  • A partially written line is never emitted. Only bytes up to the last newline in a chunk are consumed, so an event that is still being written is picked up whole on the next poll.
  • A multi-line event is not split across polls. The last event of a chunk is held back and the stored offset stays at its first byte, so its continuation lines — a panic and its backtrace, most importantly — join it rather than becoming orphans. It is released once the file stops growing.

Structs§

LogTailer
Follows one node’s log directory.
PollOutcome
What one poll produced.
TailedEvent
An event together with where it came from — everything the sink needs to build a stable _id.