Page kind: Reference
swarmops check log#
Read a check's log of a run, or with --failed the logs of its checks that did not pass.
The run is --run RUN, else the newest run that ran CHECK (with --follow, the newest still running first), of the workspace (--ws, --ws-path, else the one around the working directory) or of the directory --dir names, on this host. Gives the log's last --tail lines, each with its number, its time since the check's start, its stream (out, err, run for the runner's own lines, or other) and its text, and whether the log ended and how: end, with the check's outcome, or runner_gone. With --follow it then prints one envelope a line for each batch of lines the check writes, looking again every --interval-ms, and ends with the envelope that holds the log's end, exit 0; --human prints the lines as the log holds them. Reads only: no identity, nothing written, no store operation.
--failed, in place of CHECK, reads the log of every check that did not pass in the run --run names, else in the newest run: the first one's log is the answer, as check log gives it for that check, failed names all of them in run order, and more holds the logs of the others, each its last --tail lines; at most 20 logs and 100,000 lines, the rest counted in logs_omitted. A run with one failed check answers that log alone. A run where none failed is E_INVALID_ARG. --human prints the logs one after another, a line ==> NAME <== before each when there are several. --run-lines DIR, with --run, finds the run through the run lines in DIR instead of a workspace or --dir: its line names where the run was kept.
- Group
checks- Since
0.13.0- Mutates
- no
- Identity required
- no
- MCP tool
check_log- Envelope op
check_log- Exit codes
- 02
- Errors
- E_INVALID_ARG
Syntax#
swarmops check log [OPTIONS] [CHECK]Required arguments#
None.
Optional arguments#
The command also takes the global options.
Syntax: --ws <NAME>.
The workspace, by its name in the store's registry (default: the one around the working directory).
Syntax: --ws-path <DIR>.
The workspace's directory.
Syntax: --dir <DIR>.
Read a run of the checks of DIR on this host, as check run --dir kept it.
Syntax: <CHECK>.
The check whose log to read.
Syntax: --failed.
Read the logs of the checks of the run that did not pass, in place of CHECK's.
Syntax: --run-lines <DIR>.
Find the run through the run lines in DIR, which name where it was kept.
Syntax: --run <RUN>.
The run, by its id (default: the newest that ran CHECK, or with --failed the newest).
Syntax: --tail <N>.
Default: 1000.
The most lines to give first, the last ones; with --failed, of each log.
Syntax: --follow.
Then print the lines the check writes as it writes them, until its log ends.
Syntax: --interval-ms <N>.
Default: 200.
With --follow: how many milliseconds to wait before looking again.
Examples#
SWARMOPS_CHECK_RUNS_DIR=[tmp]/runs swarmops check log --dir [tmp]/tree sectionsShow 52 more lines
"log":Exit code 0. Recorded by the CLI tests. A name in square brackets, such as [tmp] or [c1], stands for what differs from run to run: the test's temporary directory, an id, a time.
No recorded example yet.
Details#
check log reads one check's log of a run of check run, on the host the run ran on, once or as
it grows; with --failed, in place of a check's name, it reads the logs of every check of the run
that did not pass. It reads only: nothing is written, no store operation is called, and the run's lock is
only tried, for an instant, on a descriptor opened to read, to tell a running run from one whose
runner is gone; a lock it cannot open or try (another account's run) is taken as held.
Which run#
--run RUN names a run by its id (the run of check run's answer); else it is the newest run
that ran CHECK, and with --follow the newest of those still running first. The runs are those
of the workspace (--ws, --ws-path, or the one around the working directory, found as the ws
commands find it, with no store opened), kept in its .swarmws/check-runs/, or with --dir DIR
those of DIR below SWARMOPS_CHECK_RUNS_DIR or the state directory, as check run --dir kept
them. No run that ran CHECK, or a --run that is not there, is E_INVALID_ARG with
details.reason: run.
With --failed the run is --run RUN, else the newest run of the workspace or directory, by its
id, whether it still runs or has ended.
--run-lines DIR, with --run RUN, finds the run through its
run lines in DIR instead: it goes with neither --dir
nor --ws, and reads from any working directory. The newest line of that run names its run
directory, run_dir, which must be absolute and named as the run; the run is then read there as
any other, its record and its logs, for CHECK and for --failed alike. Only the flag does
this: SWARMOPS_CHECK_RUN_LINES_DIR does not change how check log finds a run. Refused, each
E_INVALID_ARG:
details.reason | When |
|---|---|
run | The lines hold no line of that run, or RUN is not a run's id. |
run_dir | Its line names no run directory (a path past 1,024 bytes is left out of a line), or one of another name. The hint names --dir and --ws. |
run_gone | The directory is not there any more: a host keeps the newest 20 runs of a directory or workspace. details.failed names the checks of the run that its lines say did not pass. |
The log's format#
UTF-8 text, a line of the log for each line of the check's output, each
<seconds>.<milliseconds> <stream> <text>the time since the check's start (seconds right-aligned in five places), the stream (out for
stdout, err for stderr, run for the runner's own line) and the line's text, without its \n
and one \r before it, bytes that are not UTF-8 replaced. Each stream's lines are in their own
order; the two streams are read apart, so lines of stdout and stderr written close together may
interleave otherwise than written. The runner's lines are run <event> <JSON object>:
| Event | When | Object |
|---|---|---|
start | The first line. | check, run, stage, tree (null in the directory form), attempt, argv, dir, timeout_s, started_at_ms (the wall clock, Unix milliseconds). |
section | A line swarmops:section <title> of the check's output. | n, from 1, and title. |
cut | The log reached its bound. | limit. |
end | The last line, once the output ended. | outcome, exit_code or signal when there is one, duration_ms, sections (each n, title, start_ms, duration_ms), dropped_bytes. |
A check opens a section with a line, on either stream, whose text starts with
swarmops:section and whose rest, trimmed, is the title: that line is written as the runner's
section line, not as output. A section lasts until the next one opens or the output ends;
output before the first belongs to none. A title past 200 bytes is cut at a character's end with
…; past 1,000 sections a marker is an ordinary line; an empty title makes it an ordinary line.
check run's answer gives each check's sections too.
Bounds. A log holds at most 64 MiB: past it one cut line is written and later output is
counted in the end line's dropped_bytes, not written; the outcome stands. A line keeps at most
16 KiB of text, the rest counted the same way. The answer's tails come from all of the output.
A reader reads a log as a stream, keeping only the lines it gives, and no further than 65 MiB
from its start, which no run writes past: a longer file, which a check writing to its own log's
path could leave, counts only the lines within that. A log that is not a regular file (a link,
which is not followed, a FIFO, a device) is E_IO. A run's run.json is read the same way: one
that is not a regular file is E_IO, and one longer than 64 MiB is not read, its run as one that
is not there.
The format is SwarmOps' own and provisional: it may change before logs are kept beside the store.
The answer#
lines are the last --tail lines (1 to 100,000; 1,000 by default), each with its number n,
its at_ms, its stream and its text; a line not in the format, which a check writing into its
own log could leave, is other, whole, with no time. first_line and total_lines say where they
are. ended says whether the log is complete, and ended_by how: end, its end line (with the
check's outcome and duration_ms), or the run's record of a check it never started (not_run,
no log) or skipped for a need that did not pass (skipped, no log); or runner_gone, the run's lock free with no end line, as a check run killed by
SIGKILL leaves it.
The failed checks' logs#
check log --failed answers for every check of the run's record whose outcome is not passed,
in run order: failed, timed_out, not_started, cancelled, skipped and, once the run has
ended, not_run. Each one's log is read as check log NAME --run RUN --tail N reads it, so a check
with no log answers no line and its outcome from the record.
| Field | Type | Present | Meaning |
|---|---|---|---|
failed | array of strings | with --failed | Every check of the run that did not pass, in run order. |
more | array of logs | with --failed, when more than one log is given | The logs of the failed checks after the first, in run order, each with the keys of the answer above. |
logs_omitted | integer | when not 0 | The failed checks whose logs this answer leaves out; failed names them. |
The rest of the answer is the first failed check's log. A run with one failed check answers
that log alone: the envelope is what check log NAME gives, with failed naming it and no
more, and --human prints byte for byte what check log NAME --human prints. With several,
--human prints the logs one after another, a line ==> NAME <== before each.
One answer gives at most 20 logs, and no more than keep --tail times their count within 100,000
lines: the first min(failed, 20, max(1, 100,000 / tail)) in run order. With the default tail of
1,000, that is 20 logs; with --tail 100000, one. The others are read with a check log NAME
each.
A run where no check failed is E_INVALID_ARG with details.reason: none_failed, details.run
and details.running, whether the run's lock is held: of a run that still runs, a check not
started yet is not counted, so the answer is none_failed until a check of it has ended without
passing, and the hint says to wait or to follow one check. --failed goes with neither CHECK
nor --follow: the command line refuses both.
--follow#
check log --follow first prints the answer above, then, each time the check wrote whole lines
since its last look, one envelope with those lines (at most 1,000 an envelope), one envelope a
line of stdout, flushed at once, as derive --follow prints its envelopes. A look that finds
nothing prints nothing, and the next is --interval-ms later (200 by default). It ends with the
envelope that holds the log's end, ended: true, and exits 0; a follower started before its check
starts waits for the log to appear while the run runs. With --human it prints the log's lines as
the log holds them, each control character escaped (\u{1b} for ESC, \t for a tab), so that what
a check printed cannot drive the terminal; and nothing else. Output it cannot write ends it,
exit 1, with a line on stderr. A log is followed on its own host only.
The MCP tool#
swarmops mcp serves the workspace form as the tool check_log (CheckLogReq: workspace,
check or failed, run, tail), one answer per call: there is no --follow, since a tool
call answers once, no directory form and no --run-lines. Exactly one of check and
failed: true is given; neither or both is E_INVALID_ARG with details.reason: check. With
failed the answer is the one above, each log its last tail lines.
Return information#
result is a CheckLogResp (swarmops schema CheckLogResp prints its JSON Schema).
| Field | Type | Required | Description |
|---|---|---|---|
check | string | yes | The check's name. |
duration_ms | integer or null | no | The check's milliseconds, when its log's end line gives them. |
ended | boolean | yes | Whether the log is complete: no line follows. |
ended_by | CheckLogEnd or null | no | How it ended, when ended. |
failed | array of string | no | With failed: every check of the run that did not pass, in run order; check is the first of them. Omitted for one check's log. |
first_line | integer | yes | The number of the first line given, from 1. |
lines | array of CheckLogLineOut | yes | The lines given, in order. |
log | string or null | no | The log's path on the host it ran on. Omitted for a check the run never started (not_run) or skipped (skipped), which has none. |
logs_omitted | integer | no | With failed: the failed checks whose logs this answer leaves out, past 20 logs or 100,000 lines; failed names them. Omitted when 0. |
more | array of CheckLogMoreOut | no | With failed: the logs of the failed checks after the first, in run order. Omitted when there is no other. |
outcome | CheckOutcome or null | no | The check's outcome, when ended_by is end. |
run | string | yes | The run's id. |
total_lines | integer | yes | The log's lines so far. |
vouched | boolean | yes | As the run's: true for a run of the directory form. |
Envelope op: check_log.
Exit codes:
0: Success.2: The request or the command line is malformed.
Errors#
- E_INVALID_ARG (exit 2): A malformed argument or request, including a command-line usage error.
Any command that opens a store may also fail with a store error, such as E_NOT_A_REPO, E_IO or E_STORE_CORRUPT; a command line the grammar refuses is E_INVALID_ARG (exit 2).