Skip to content

feat(tamanu/logs): TAM-6782: multi-name + unified caddy tailing#353

Merged
passcod merged 4 commits into
mainfrom
feat/tamanu-logs-multiname
May 23, 2026
Merged

feat(tamanu/logs): TAM-6782: multi-name + unified caddy tailing#353
passcod merged 4 commits into
mainfrom
feat/tamanu-logs-multiname

Conversation

@passcod
Copy link
Copy Markdown
Member

@passcod passcod commented May 23, 2026

🤖

Stacked on #352.

Reshapes tamanu logs to share the matcher surface introduced by the lifecycle PR. Splitting from the lifecycle PR keeps each diff reviewable on its own — this one only touches logs.rs (plus a small refactor to move match_names to where Expectation lives).

What changed

  • LogsArgs.name: StringLogsArgs.names: Vec<String>. Each name is a substring matched against the expected-Up service list via services::match_names (lifted from the lifecycle PR's lifecycle.rs into services.rs so logs can use it without the tamanu-lifecycle feature).
  • The literal pseudo-service caddy is recognised as a named match alongside tamanu names. bestool tamanu logs caddy api is now a single combined tail.
  • With no names at all, every expected-Up tamanu service plus caddy is tailed: bestool tamanu logs is the all-stack tail operators want.

Behaviour

On Linux the union collapses to a single journalctl call: journalctl -u <unit1> -u <unit2> ... -u caddy.service -n N [-f] [-g REGEX] --output=cat. The existing content-based JSON highlighter (already opportunistic per line) is reused, so caddy lines render coloured and tamanu lines pass through unchanged in the same stream.

On Windows tail_files already takes multiple TailSources. When caddy is in the matched set, caddy_log_files_windows() contributes its .log files alongside the pm2 sources.

Error UX

  • Any name matching zero expectations and not the literal caddy: bail with the available names (same UX as lifecycle commands).
  • caddy always matches; it's not subject to discovery.

passcod added 4 commits May 23, 2026 17:01
The matcher is the only pure piece of lifecycle.rs — it operates on
Expectation and has no IO. Moving it to services.rs alongside the
Expectation type means logs.rs (which doesn't pull in the
tamanu-lifecycle feature) can share the same primitive without a
cross-feature dependency.
…to the main tail

LogsArgs.name (single String) becomes LogsArgs.names (Vec<String>).
Each name is a substring against the expected service list (matched
via services::match_names). The literal pseudo-service `caddy` is
recognised alongside tamanu names, so `tamanu logs caddy api` is a
single combined tail. With no names, every expected-Up tamanu service
plus caddy is tailed — `tamanu logs` alone is now the all-stack tail
operators want.

On Linux this collapses to one journalctl call with `-u <unit1> ...`
plus `-u caddy.service` when caddy is matched, all piped through the
existing JSON highlighter. On Windows, the pm2 log sources are merged
with caddy's .log files into a single `tail_files` call.
The reshape is shipped: LogsArgs takes variadic NAMES, the matcher is
shared via services::match_names, caddy is a recognised pseudo-service
in the unified tail, and the empty-NAMES default tails the whole
stack.
@passcod passcod force-pushed the feat/tamanu-logs-multiname branch from 5b3c3cd to 6c1057c Compare May 23, 2026 05:02
Base automatically changed from feat/tamanu-lifecycle to main May 23, 2026 06:49
@passcod passcod added this pull request to the merge queue May 23, 2026
Merged via the queue into main with commit 7fb97f2 May 23, 2026
9 of 16 checks passed
@passcod passcod deleted the feat/tamanu-logs-multiname branch May 23, 2026 07:10
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