Skip to content

Add tail to follow a fleet's logs - #35

Closed
siliconwitch wants to merge 2 commits into
mainfrom
dev
Closed

siliconwitch wants to merge 2 commits into
mainfrom
dev

Conversation

@siliconwitch

Copy link
Copy Markdown
Member

superstack tail <fleet_id> [imei ...] [-n num] [--log-file <file>] follows one fleet's logs, or only the named devices in it.

It prints the newest num logs, 10 unless given, then each new log as the server's long poll returns it. A request that fails to connect, times out, or gets a 5xx answer is retried from the same cursor after 1, 2, 4, then 10 seconds, so no line is lost or repeated. Any 4xx answer ends the command with the server's message.

Each line is the local date and time the server received the log, the device's name or IMEI, the kind in brackets, and the text:

2026-10-02 12:01:07 kitchen[lifecycle]: Code started
2026-10-02 12:01:07 kitchen[lua]: hello	1
2026-10-02 12:01:09 kitchen[error]: Code crashed: main.lua:3: attempt to index a nil value

Tabs, quotes, and backslashes print as the device sent them, so a print looks as it does in desktop Lua. Other control characters and non-graphic runes are escaped, so device output cannot drive the terminal. --log-file appends the same lines to a file.

It needs the server change that adds GET /fleets/{id}/logs. Against a server without that route, tail ends with the server's message.

Checks: CGO_ENABLED=0 go build ./..., go vet ./..., go test ./..., and gofmt -l . pass, and go mod tidy changes nothing. TestTheModuleStaysDependencyFree passes and const version is unchanged. The built binary was also exercised against a local server and a test device: history, a whole fleet, named devices, a device outside the fleet, an unknown fleet, and a server stopped and restarted mid-session.

tail takes one fleet id and optional IMEIs. It prints the newest logs,
then each new one as the server's long poll returns it, and retries a
dropped connection from the same cursor so no line is lost or repeated.

Each line is the local time the server received the log, the device's
name or IMEI, the kind in brackets, and the text. Tabs, quotes, and
backslashes print as the device sent them. Other control characters are
escaped so device output cannot drive the terminal.
-n has no upper limit and pages through the server's answers. Each line is time, IMEI, kind, then the name in brackets. --log-file is gone, and tail's own notices go to the error stream so the output holds only logs.
@siliconwitch

Copy link
Copy Markdown
Member Author

Abandoned. The transport work restarts from the rewritten design.md, and logging follows in its own cycle. The branch is kept as tail-reference.

@siliconwitch
siliconwitch deleted the dev branch October 5, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant