Skip to content

Commit 103f44a

Browse files
rdemellowdaverigby
authored andcommitted
Fix mctiming's --json=pretty flag
Currently mctiming's doesn't respect the pretty arg to --json and instead produces json in pretty format at all times. To fix this only dump() json with indentation when the pretty flag has be set. Also ensure we don't print the histogram legend when the pretty is set. Change-Id: Ib1b8f47c57a00ac0babb7c624b7291a06c35144d Reviewed-on: http://review.couchbase.org/c/kv_engine/+/151170 Tested-by: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent aa77209 commit 103f44a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

programs/mctimings/mctimings.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <stdexcept>
3030
#include <string>
3131

32+
#define JSON_DUMP_NO_INDENT -1
3233
#define JSON_DUMP_INDENT_SIZE 4
3334

3435
const static std::string_view histogramInfo = R"(Histogram Legend:
@@ -511,7 +512,7 @@ int main(int argc, char** argv) {
511512
connection.selectBucket(bucket);
512513
}
513514

514-
if (verbose) {
515+
if (verbose && !json) {
515516
fmt::print(stdout, histogramInfo);
516517
}
517518

@@ -547,7 +548,10 @@ int main(int argc, char** argv) {
547548
}
548549
}
549550
if (jsonOutput.has_value()) {
550-
fmt::print(stdout, "{}\n", jsonOutput->dump(JSON_DUMP_INDENT_SIZE));
551+
fmt::print(stdout,
552+
"{}\n",
553+
jsonOutput->dump(verbose ? JSON_DUMP_INDENT_SIZE
554+
: JSON_DUMP_NO_INDENT));
551555
}
552556
} catch (const ConnectionError& ex) {
553557
fmt::print(stderr, "{}\n", ex.what());

0 commit comments

Comments
 (0)