Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
fileignoreconfig:
- filename: src/logs/logs.inputs.test.ts
checksum: 7b4df8790179c7dc4385acd1d380bb91397523bab111593742e2fc53c94da375
- filename: test/integration/logs-get.test.ts
checksum: 7822d714f476fa4ee588f1b602a7c9e69b8843cc60c09b4ae14cbe4eb2b4ad3b
checksum: 909965f29b2e6a0b6220b22c175b4a39edc05759fba1274a7a1f2f750a7e0e3b
- filename: src/commands/launch/logs/get.test.ts
checksum: 5ee3d8ba6b014b3a9ac558a750a9a58782bb679d32d30b621e41f977dcc98a0a
checksum: d94d390de150956c799f64a84adfe0e02b5b21c66ddcc5cf55a1329aa67ec1a7
- filename: src/core/failure.test.ts
checksum: 242d43885d1e3ef46edf1e347899a90549ebf95ec6827426746852f7a6dfc418
- filename: test/integration/retired-commands.test.ts
Expand Down Expand Up @@ -229,12 +231,12 @@ fileignoreconfig:
allowed_patterns:
- "FlagKey"
- filename: src/resources.test.ts
checksum: beb9cd5f1d8a0c73c15db7a82e5d5feb9b3418bb1d29dab5191eec947e91fa81
checksum: 6ff9df735323c036cbd5eb5fb321fef110a05b7ae99e61d7687bebc2c0b6dde1
allowed_patterns:
- "a project name passed on argv to the project resolver"
- "expect\\(Object.keys\\(DEPENDENCIES\\)\\).toEqual\\(\\['project', 'env'\\]\\)"
- filename: AGENTS.md
checksum: aafd85677e293bf72dd5764875b202ac3a5531aa083c1c452adaa55021af8c95
checksum: ba37b6b17d97940a6f7d5e69a531796ab0ee5b6859a9cd5cbdec56e4b7731b26
allowed_patterns:
- "Do not add an exemption to a guard to make a new file pass"
- "passes its own error wording to `client.request\\(req, MESSAGES\\)`"
Expand Down Expand Up @@ -330,7 +332,7 @@ fileignoreconfig:
- filename: src/commands/launch/env/update.test.ts
checksum: 2da219594e7bdd589adc0eff9ff035252a75aaa51dfa20514b18fd3266d7b752
- filename: README.md
checksum: 20f317d623537458342d10926c2442f5674fd26b8a023599fec4626a0d0ac5ba
checksum: b6af89e3dea468d56b666f4098a9b2224a5224ca45c9e94f7970d9e6674f3e6e
allowed_patterns:
- "password-protection"
- "-p, --password"
Expand Down
18 changes: 14 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ src/
git/ the internal git-namespace / repository / branch lookups
organizations/ the --org flag, its organization picker, and the lookup behind it,
which reads the Contentstack Management API rather than Launch
logs/ logs:get: the server-log window parser and repository, the live log API over SSE, and
the LiveLogFollower that reconnects it; the build-log follow is deployments'. It
reaches deployments only
logs/ logs:get: the server-log window parser, the server-log repository and its cursor walk,
the live log API over SSE, and the LiveLogFollower that reconnects it; the build-log
follow is deployments'. It reaches deployments only
cache/ the CDN cache purge behind launch:cache:purge: CacheApi, the --path / --prefix / --tags / --hosts
inputs and their normalisation, the criterion prompt and the success lines
site/ the URL choice for an environment's live site (`siteUrlOf`, shared with the deployment follower),
Expand Down Expand Up @@ -495,7 +495,7 @@ promoting these to `src/core/catalog.ts` now.
| 0 | none - oclif exits 0 implicitly | the command did what it was asked to do |
| 1 | `EXIT_RUNTIME` | a runtime failure - `LaunchApiError`, `LaunchNetworkError`, `UnauthenticatedError`, anything oclif handles |
| 2 | `EXIT_USAGE` | a usage error - `UsageError`, `MissingInputError`, a failing cross-flag rule |
| 3 | `EXIT_CANCELLED` | the user declined a confirmation, chose nothing at a picker (`CancelledError`) or pressed Ctrl-C while the CLI was following a deployment's logs or a live log stream (`logs:get`) |
| 3 | `EXIT_CANCELLED` | the user declined a confirmation, chose nothing at a picker (`CancelledError`) or pressed Ctrl-C while the CLI was following a deployment's logs, walking server-log pages or following a live log stream (`logs:get`) |

`launch:functions:serve` is deliberately a plain oclif `Command` rather than a
`LaunchCommand`, because it talks to no API and needs no auth gate, and it is **outside**
Expand Down Expand Up @@ -746,6 +746,16 @@ server's own 5-minute cap: it exits 0 and is never followed by a reconnect. Ctrl
sleep and the socket listen to, exit 3. The header builder, `buildRequestHeaders` in `rest-client.ts`, is the only place
`X-CS-CLI`, `x-cs-api-version`, the auth headers and the org/project scope headers are assembled.

**Server logs are a cursor walk.** `logs:get --type server` reads `GET …/logs/server-logs` oldest-first
(`sortDirection=asc`) through `ServerLogsApi.pages`, which follows `pageInfo.newestCursor` with the same window,
`--search` and `--cursor` and prints each page as it arrives, so a window is never held in memory. `nextCursorOf`
is the one rule for "this page leads to another": `hasNewer` true, a non-empty page and a non-blank cursor. The walk
also ends after `MAX_PAGES` pages, and a logs service without `pageInfo` (before CL-7180) ends it after one. When the
last page still leads on, at the cap or on Ctrl-C (exit 3, after the page in hand is printed), the command prints a
`Resume with:` command whose `--since`/`--until` are the **absolute** window of the run: re-resolving a relative
`--since` on resume would move the start past the cursor and silently skip the logs between. The cursor is opaque;
the CLI prints it single-quoted and never parses it, and the server's `INVALID_CURSOR` is the only check on it.

**Writing a test for it: the fake clock must advance.** `now()` and `sleep()` are injected and both
are required, not optional with defaults. A fake `now: () => 0` with a `sleep` that does nothing
makes the deadline unreachable and the suite **hangs** rather than failing - the same failure mode
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -560,15 +560,17 @@ Read the build or server logs of a deployment of a Launch environment
```
USAGE
$ csdx launch:logs:get [-c <value>] [-d <value>] [--org <value>] [--project <value>] [--env <value>] [--deployment
<value>] [--since <value>] [--until <value>] [--type <value>]
<value>] [--since <value>] [--until <value>] [--search <value>] [--cursor <value>] [--type <value>]

FLAGS
-c, --config=<value> Path to the local '.cs-launch.json' file
-d, --data-dir=<value> Current working directory
--cursor=<value> Server logs only: resume from the cursor printed by an earlier run
--deployment=<value> Deployment UID
--env=<value> Environment name or UID
--org=<value> Organization UID
--project=<value> Project name or UID
--search=<value> Server logs only: show only lines containing this text, up to 256 characters
--since=<value> Server logs only: start of the window, relative (45s, 30m, 12hr, 2d) or an ISO 8601
timestamp with an offset. Defaults to one hour before --until
--type=<value> Kind of logs to read (deployment | server | live). Defaults to deployment
Expand Down
Loading
Loading