Text output plugin argument parsing
[babeltrace.git] / plugins / text / print.c
index 2b1be1fc09f39414602c1a52fc8d0d414b772a55..41e2dd2aec2caae33967495b82e4b50381c041b1 100644 (file)
@@ -137,6 +137,10 @@ enum bt_component_status print_event_header(struct text_component *text,
                ret = BT_COMPONENT_STATUS_ERROR;
                goto end;
        }
+       if (!text->start_line) {
+               fputs(", ", text->out);
+       }
+       text->start_line = false;
        ret = print_event_timestamp(text, event);
        if (ret != BT_COMPONENT_STATUS_OK) {
                goto end;
@@ -693,8 +697,12 @@ enum bt_component_status print_stream_packet_context(struct text_component *text
                ret = BT_COMPONENT_STATUS_ERROR;
                goto end;
        }
+       if (!text->start_line) {
+               fputs(", ", text->out);
+       }
+       text->start_line = false;
        if (text->options.print_scope_field_names) {
-               fputs(" stream.packet.context = ", text->out);
+               fputs("stream.packet.context = ", text->out);
        }
        ret = print_field(text, main_field,
                        text->options.print_context_field_names);
@@ -716,11 +724,15 @@ enum bt_component_status print_event_header_raw(struct text_component *text,
                ret = BT_COMPONENT_STATUS_ERROR;
                goto end;
        }
+       if (!text->start_line) {
+               fputs(", ", text->out);
+       }
+       text->start_line = false;
        if (text->options.print_scope_field_names) {
-               fputs(" stream.event.header = ", text->out);
+               fputs("stream.event.header = ", text->out);
        }
        ret = print_field(text, main_field,
-                       text->options.print_context_field_names);
+                       text->options.print_header_field_names);
 end:
        bt_put(main_field);
        return ret;
@@ -738,8 +750,12 @@ enum bt_component_status print_stream_event_context(struct text_component *text,
                ret = BT_COMPONENT_STATUS_ERROR;
                goto end;
        }
+       if (!text->start_line) {
+               fputs(", ", text->out);
+       }
+       text->start_line = false;
        if (text->options.print_scope_field_names) {
-               fputs(" stream.event.context = ", text->out);
+               fputs("stream.event.context = ", text->out);
        }
        ret = print_field(text, main_field,
                        text->options.print_context_field_names);
@@ -760,8 +776,12 @@ enum bt_component_status print_event_context(struct text_component *text,
                ret = BT_COMPONENT_STATUS_ERROR;
                goto end;
        }
+       if (!text->start_line) {
+               fputs(", ", text->out);
+       }
+       text->start_line = false;
        if (text->options.print_scope_field_names) {
-               fputs(" event.context = ", text->out);
+               fputs("event.context = ", text->out);
        }
        ret = print_field(text, main_field,
                        text->options.print_context_field_names);
@@ -782,8 +802,12 @@ enum bt_component_status print_event_payload(struct text_component *text,
                ret = BT_COMPONENT_STATUS_ERROR;
                goto end;
        }
+       if (!text->start_line) {
+               fputs(", ", text->out);
+       }
+       text->start_line = false;
        if (text->options.print_scope_field_names) {
-               fputs(" event.fields = ", text->out);
+               fputs("event.fields = ", text->out);
        }
        ret = print_field(text, main_field,
                        text->options.print_payload_field_names);
@@ -798,40 +822,31 @@ enum bt_component_status text_print_event(struct text_component *text,
 {
        enum bt_component_status ret;
 
-       //TEST XXX
-       text->options.print_scope_field_names = true;
-       text->options.print_payload_field_names = true;
-       text->options.print_context_field_names = true;
-
+       text->start_line = true;
        ret = print_event_header(text, event);
        if (ret != BT_COMPONENT_STATUS_OK) {
                goto end;
        }
-       fputs(",", text->out);
 
        ret = print_stream_packet_context(text, event);
        if (ret != BT_COMPONENT_STATUS_OK) {
                goto end;
        }
-       fputs(",", text->out);
 
        ret = print_event_header_raw(text, event);
        if (ret != BT_COMPONENT_STATUS_OK) {
                goto end;
        }
-       fputs(",", text->out);
 
        ret = print_stream_event_context(text, event);
        if (ret != BT_COMPONENT_STATUS_OK) {
                goto end;
        }
-       fputs(",", text->out);
 
        ret = print_event_context(text, event);
        if (ret != BT_COMPONENT_STATUS_OK) {
                goto end;
        }
-       fputs(",", text->out);
 
        ret = print_event_payload(text, event);
        if (ret != BT_COMPONENT_STATUS_OK) {
This page took 0.025725 seconds and 4 git commands to generate.