json: support BORG_JSON_COMPACT env var for single-line output#9855
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9855 +/- ##
==========================================
+ Coverage 85.11% 85.13% +0.01%
==========================================
Files 93 93
Lines 15408 15421 +13
Branches 2326 2329 +3
==========================================
+ Hits 13114 13128 +14
+ Misses 1596 1595 -1
Partials 698 698 ☔ View full report in Codecov by Harness. |
|
Maybe not directly relevant to this PR, but might as well put it here: JSON output is meant to be read programmatically, right? Why isn't it default to output the most compact form possible to spare the extra work? Users can set the indent envvar or pipe into |
|
@Goddesen good idea, guess we could change the default for borg2. |
|
@charmikadi Thanks! Can you please do a backport to 1.4-maint branch? |
Description
When BORG_JSON_COMPACT is set, json_dump() produces single-line JSON instead of the default indented output. This makes it easier for log collectors to parse borg's JSON stdout as one event per line. Implementation uses an env var and not CLI flag.
Fixes #3605
Checklist
mastertoxor the relevant test subset)