feat(tamanu/logs): TAM-6782: multi-name + unified caddy tailing#353
Merged
Conversation
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.
5b3c3cd to
6c1057c
Compare
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.
🤖
Stacked on #352.
Reshapes
tamanu logsto share the matcher surface introduced by the lifecycle PR. Splitting from the lifecycle PR keeps each diff reviewable on its own — this one only toucheslogs.rs(plus a small refactor to movematch_namesto where Expectation lives).What changed
LogsArgs.name: String→LogsArgs.names: Vec<String>. Each name is a substring matched against the expected-Up service list viaservices::match_names(lifted from the lifecycle PR'slifecycle.rsintoservices.rsso logs can use it without thetamanu-lifecyclefeature).caddyis recognised as a named match alongside tamanu names.bestool tamanu logs caddy apiis now a single combined tail.bestool tamanu logsis the all-stack tail operators want.Behaviour
On Linux the union collapses to a single
journalctlcall: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_filesalready takes multipleTailSources. When caddy is in the matched set,caddy_log_files_windows()contributes its.logfiles alongside the pm2 sources.Error UX
caddy: bail with the available names (same UX as lifecycle commands).caddyalways matches; it's not subject to discovery.