From a2593a556e052d8e8d06f7b3e227cbae0901c0ff Mon Sep 17 00:00:00 2001 From: Castulo Martinez Date: Mon, 29 Apr 2019 22:20:54 +0000 Subject: [PATCH] Print the json output to stdout instead of stderr Signed-off-by: Castulo Martinez --- src/lib/formatter_json.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib/formatter_json.c b/src/lib/formatter_json.c index 6d181746..3ecf48a7 100644 --- a/src/lib/formatter_json.c +++ b/src/lib/formatter_json.c @@ -45,24 +45,24 @@ void set_json_format(void) void json_start(const char *op) { if (json_format) { - fprintf(stderr, "[\n{ \"type\" : \"start\", \"section\" : \"%s\" },\n", op); - fflush(stderr); + fprintf(stdout, "[\n{ \"type\" : \"start\", \"section\" : \"%s\" },\n", op); + fflush(stdout); } } void json_end(const char *op, int status) { if (json_format) { - fprintf(stderr, "{ \"type\" : \"end\", \"section\" : \"%s\", \"status\" : %d }\n]\n", op, status); - fflush(stderr); + fprintf(stdout, "{ \"type\" : \"end\", \"section\" : \"%s\", \"status\" : %d }\n]\n", op, status); + fflush(stdout); } } void json_status(int status) { if (json_format) { - fprintf(stderr, "{ \"type\" : \"status\", \"status\" : %d },\n", status); - fflush(stderr); + fprintf(stdout, "{ \"type\" : \"status\", \"status\" : %d },\n", status); + fflush(stdout); } } @@ -95,8 +95,8 @@ void json_message(const char *msg_type, const char *msg, va_list args_list) /* add the JSON format and print immediately */ if (strcmp(full_msg, " ") != 0) { - fprintf(stderr, "{ \"type\" : \"%s\", \"msg\" : \"%s\" },\n", type ? type : "info", full_msg); - fflush(stderr); + fprintf(stdout, "{ \"type\" : \"%s\", \"msg\" : \"%s\" },\n", type ? type : "info", full_msg); + fflush(stdout); } free_string(&full_msg); @@ -107,7 +107,7 @@ void json_message(const char *msg_type, const char *msg, va_list args_list) void json_progress(char *step_description, unsigned int current_step, unsigned int total_steps, int percentage) { - fprintf(stderr, "{ \"type\" : \"progress\", " + fprintf(stdout, "{ \"type\" : \"progress\", " "\"currentStep\" : %d, " "\"totalSteps\" : %d, " "\"stepCompletion\" : %d, "