Add machine-readable (JSON) log output to all CLI tools#57
Add machine-readable (JSON) log output to all CLI tools#57sjoerdsimons with Copilot wants to merge 3 commits into
Conversation
ece0bed to
dd05896
Compare
|
@andrewshadura tagging you in as this is a fixed for an issue you filed ;) |
There was a problem hiding this comment.
Pull request overview
Adds a new --log-format {pretty,json} CLI option across all binaries so logs can be consumed programmatically (JSON) while preserving existing human-readable output (pretty). This fits the codebase by standardizing tracing initialization across the CLI tools and enabling tracing-subscriber’s JSON formatter consistently.
Changes:
- Enable
tracing-subscriber’sjsonfeature in each binary crate. - Add
LogFormat+--log-formatand refactor tracing subscriber setup intoinit_tracing(...)in eachmain.rs. - Adjust startup order to parse CLI args before initializing tracing, then install
color-eyre(plus a smallclippywarning fix inaptlyctl/src/repo.rs).
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| obs2aptly/src/main.rs | Adds --log-format and initializes tracing via init_tracing(LogFormat). |
| obs2aptly/Cargo.toml | Enables tracing-subscriber JSON support for machine-readable logs. |
| aptlyctl/src/main.rs | Adds --log-format and refactors subscriber initialization into init_tracing. |
| aptlyctl/Cargo.toml | Enables tracing-subscriber JSON support. |
| aptlyctl/src/repo.rs | Fixes a pre-existing clippy warning (clippy::useless_conversion). |
| aptly-latest-snapshots/src/main.rs | Adds --log-format and moves tracing init after Opts::parse(). |
| aptly-latest-snapshots/Cargo.toml | Enables tracing-subscriber JSON support. |
| apt2aptly/src/main.rs | Adds --log-format and refactors subscriber initialization into init_tracing. |
| apt2aptly/Cargo.toml | Enables tracing-subscriber JSON support. |
| Cargo.lock | Adds dependencies required by tracing-subscriber JSON feature (serde_json, tracing-serde, etc.). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #[clap(long, env = "APTLY_API_TOKEN")] | ||
| api_token: Option<String>, | ||
| /// Log output format | ||
| #[clap(long, default_value = "pretty")] |
| #[clap(short = 'n', long, default_value_t = false)] | ||
| dry_run: bool, | ||
| /// Log output format | ||
| #[clap(long, default_value = "pretty")] |
|
@copilot please fix the review comments and rebase on the latest main if needed |
Fixed in |
b86dab4 to
d3864c0
Compare
d3864c0 to
5428b4d
Compare
5428b4d to
0a245c2
Compare
All CLI binaries only supported human-readable log output, with no way to consume logs programmatically.
Changes
{aptlyctl,apt2aptly,obs2aptly,aptly-latest-snapshots}/Cargo.toml: enable thejsonfeature fortracing-subscribermain.rs:LogFormatenum (pretty|json) withclap::ValueEnum--log-formattoOptsfn init_tracing(LogFormat)helperOpts::parse()→init_tracing()→color_eyre::install()soErrorLayeris registered before color-eyre's hook runsaptlyctl/src/repo.rs: fix pre-existingclippy::useless_conversionwarningUsage
JSON output uses
tracing-subscriber's built-in JSON formatter;pretty(the default) preserves existing behavior.