Repository navigation
Add tail to print and follow a fleet's logs - #36
Merged
Merged
Conversation
tail takes a fleet id and optional IMEIs. Without -n it follows new logs. -n prints the newest logs, and --offset skips that many of the newest first so a tool can page back.
Plain tail prints the newest 100 logs before following, and retries from the same cursor while the server is unavailable. -o replaces --offset and sends offset with last, so a window never pages. Later lines of a log are indented under the first.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tail <fleet_id> [imei ...] [-n num [-o num]]reads a fleet's logs fromGET /fleets/{id}/logs.-n, it prints the newest 100 logs, then follows the fleet until Ctrl-C. A request that fails because the network or the server is unavailable is retried from the same cursor after one second.-nprints a window of past logs and exits. It is 1 to 1,000 and is one request withlast, so it never waits and never pages.-osits the window back by that many of the newest logs, 1 or more, and needs-n. It sendsoffsetwithlast.Each log prints as
<local time with offset> <IMEI> <kind> [<name>] <text>. Later lines of a text are indented by the width of the fields, so the text forms one column. Tabs, newlines and printable characters print as they are, and every other character is escaped.CGO_ENABLED=0go build,go vet,gofmt -l,go mod tidyandgo test ./...pass. Tests cover the argument refusals, windows with and without-oincluding the largest window over 2,500 stored logs, the printed layout of a multi-line log, and a follow that prints the newest 100, retries a 503 from the same cursor, and ends on the server's refusal. The binary atc161b08ran against the server route in superstack-servered8e54d. The binary ata891f96has not run against a server.