Skip to main content

Module log_ops

Module log_ops 

Source
Expand description

app.logs.tail: the last lines of this AgentMux’s own srv or host log (spec §4.3), a read. Token shapes, private keys and card or ID numbers are hidden line by line, and the answer carries no path: only the lines and when the file was last written.

Structs§

Filter 🔒
What a caller wants out of the lines read: a minimum level and a text a line must contain. Both must hold.

Enums§

Level 🔒
A log line’s level, lowest first.

Constants§

DEFAULT_LINES 🔒
FILTERED_READ_BYTES 🔒
With a level or a text asked for, more of the file is searched, since the lines wanted may be far back among noise. A bound on the work, and the answer says how much was searched.
KEY_BEGIN 🔒
KEY_END 🔒
MAX_CONTAINS 🔒
The longest text a line can be asked to contain.
MAX_LINES 🔒
MAX_TEXT_BYTES 🔒
A cap on the text of one answer; the oldest lines go first.
READ_BYTES 🔒
How much of the end of a file is read: enough for MAX_LINES long lines, and a bound on the work.

Functions§

fit 🔒
Keeps the newest lines whose text fits max bytes; says whether any were left out.
handle_local_logs 🔒
GET /api/v1/app/logs?log=srv|host&lines=N&level=warn&contains=store: the same read for this machine’s own agents (container agents too: it goes through srv, no host file access is given out).
level_of 🔒
The level a log line carries: the logs are JSON lines with "level":"INFO" near the start. A line that has none (a wrapped continuation, text from a child process) has no level.
logs_tail 🔒
newest_log 🔒
The most recently written log file in dir whose name starts with prefix.
parse_level 🔒
level as a caller names it.
pick 🔒
The last n of the lines that pass filter, and how many passed. The filter comes first, then the cut: so “the last 100 warnings that mention store” is the last 100 of the warnings, not the warnings among the last 100.
prefix_of 🔒
The log file name prefix of which.
read_tail 🔒
The last window bytes of the file, and whether that is only part of it.
tail 🔒
The tail of this machine’s srv or host log, for app.logs.tail and for GET /api/v1/app/logs. Lines are read, masked, filtered, cut to the last lines, and fitted to the answer’s size, in that order. The answer says how many lines passed the filter (matched), out of how many were searched (searched).
window_lines 🔒
Every whole line of bytes, masked. The whole text is masked before it is split, so a private key whose BEGIN and END lines are many lines apart is hidden as one block. When from_middle the first line is a fragment of a longer one and is dropped.
without_open_key 🔒
text read from the middle of a file may start inside a private key: its BEGIN line is before the window, so the key’s body lines would not match the key mask. When an END marker comes before any BEGIN marker, everything up to the end of that line is dropped.