Add --output-format command line option
Right now we have normal, terse, and json output. Lets add a parameter
that controls how to output results, instead of having options for
both terse and json outputs. If we are going to add a 4th output
type in the future, it's only going to get more messy.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/init.c b/init.c
index ca8047b..da1f472 100644
--- a/init.c
+++ b/init.c
@@ -36,7 +36,7 @@
struct thread_data *threads = NULL;
int exitall_on_terminate = 0;
-int terse_output = 0;
+int output_format = FIO_OUTPUT_NORMAL;
int eta_print;
unsigned long long mlock_size = 0;
FILE *f_out = NULL;
@@ -117,9 +117,9 @@
.val = 'm' | FIO_CLIENT_FLAG,
},
{
- .name = (char *) "json-output",
+ .name = (char *) "output-format",
.has_arg = optional_argument,
- .val = 'J' | FIO_CLIENT_FLAG,
+ .val = 'F' | FIO_CLIENT_FLAG,
},
{
.name = (char *) "version",
@@ -875,7 +875,7 @@
if (!td->o.name)
td->o.name = strdup(jobname);
- if (!terse_output) {
+ if (output_format == FIO_OUTPUT_NORMAL) {
if (!job_add_num) {
if (!strcmp(td->io_ops->name, "cpuio")) {
log_info("%s: ioengine=cpu, cpuload=%u,"
@@ -1218,8 +1218,9 @@
printf(" --latency-log\t\tGenerate per-job latency logs\n");
printf(" --bandwidth-log\tGenerate per-job bandwidth logs\n");
printf(" --minimal\t\tMinimal (terse) output\n");
- printf(" --version\t\tPrint version info and exit\n");
+ printf(" --output-format=x\tOutput format (terse,json,normal)\n");
printf(" --terse-version=x\tSet terse version output format to 'x'\n");
+ printf(" --version\t\tPrint version info and exit\n");
printf(" --help\t\tPrint this page\n");
printf(" --cmdhelp=cmd\t\tPrint command help, \"all\" for all of"
" them\n");
@@ -1411,11 +1412,17 @@
f_err = f_out;
break;
case 'm':
- terse_output = 1;
+ output_format = FIO_OUTPUT_TERSE;
break;
- case 'J':
- terse_version = 4;
- terse_output = 1;
+ case 'F':
+ if (!strcmp(optarg, "minimal") ||
+ !strcmp(optarg, "terse") ||
+ !strcmp(optarg, "csv"))
+ output_format = FIO_OUTPUT_TERSE;
+ else if (!strcmp(optarg, "json"))
+ output_format = FIO_OUTPUT_JSON;
+ else
+ output_format = FIO_OUTPUT_NORMAL;
break;
case 'h':
if (!cur_client) {
@@ -1448,10 +1455,9 @@
}
break;
case 'V':
- if (terse_version == 4)
- break;
terse_version = atoi(optarg);
- if (!(terse_version == 2 || terse_version == 3)) {
+ if (!(terse_version == 2 || terse_version == 3) ||
+ (terse_version == 4)) {
log_err("fio: bad terse version format\n");
exit_val = 1;
do_exit++;
@@ -1687,7 +1693,7 @@
fio_gtod_cpu = def_thread.o.gtod_cpu;
}
- if (!terse_output)
+ if (output_format == FIO_OUTPUT_NORMAL)
log_info("%s\n", fio_version_string);
return 0;