Update pretty-printing output
[babeltrace.git] / formats / ctf-text / ctf-text.c
index 2ec71c56765b872a30c2ab040f865356227d75a6..882e0620eed83159510f844d9c1d5ed4e34fccff 100644 (file)
@@ -55,10 +55,11 @@ struct format ctf_text_format = {
 
 static
 int ctf_text_write_event(struct stream_pos *ppos,
-                        struct ctf_stream_class *stream_class)
+                        struct ctf_stream *stream)
 {
        struct ctf_text_stream_pos *pos =
                container_of(ppos, struct ctf_text_stream_pos, parent);
+       struct ctf_stream_class *stream_class = stream->stream_class;
        struct ctf_event *event_class;
        uint64_t id = 0;
        int len_index;
@@ -92,23 +93,28 @@ int ctf_text_write_event(struct stream_pos *ppos,
                return -EINVAL;
        }
 
-       if (field_nr++ != 0)
-               fprintf(pos->fp, ", ");
        if (pos->print_names)
                fprintf(pos->fp, "timestamp = ");
        else
                fprintf(pos->fp, "[");
-       fprintf(pos->fp, "%" PRIu64, (uint64_t) 0);     /* TODO */
+       fprintf(pos->fp, "%12" PRIu64, stream->timestamp);
        if (!pos->print_names)
                fprintf(pos->fp, "]");
 
-       if (field_nr++ != 0)
+       if (pos->print_names)
                fprintf(pos->fp, ", ");
+       else
+               fprintf(pos->fp, " ");
        if (pos->print_names)
                fprintf(pos->fp, "name = ");
-       fprintf(pos->fp, "%s: ", g_quark_to_string(event_class->name));
+       fprintf(pos->fp, "%s", g_quark_to_string(event_class->name));
+       if (pos->print_names)
+               field_nr++;
+       else
+               fprintf(pos->fp, ": ");
 
-       if (stream_class->event_header) {
+       /* Only show the event header in verbose mode */
+       if (babeltrace_verbose && stream_class->event_header) {
                if (field_nr++ != 0)
                        fprintf(pos->fp, ", ");
                if (pos->print_names)
@@ -124,7 +130,6 @@ int ctf_text_write_event(struct stream_pos *ppos,
                        fprintf(pos->fp, ", ");
                if (pos->print_names)
                        fprintf(pos->fp, "stream.event.context = ");
-               fprintf(pos->fp, " ");
                ret = generic_rw(ppos, &stream_class->event_context->p);
                if (ret)
                        goto error;
@@ -136,7 +141,6 @@ int ctf_text_write_event(struct stream_pos *ppos,
                        fprintf(pos->fp, ", ");
                if (pos->print_names)
                        fprintf(pos->fp, "event.context = ");
-               fprintf(pos->fp, " ");
                ret = generic_rw(ppos, &event_class->context->p);
                if (ret)
                        goto error;
@@ -148,7 +152,6 @@ int ctf_text_write_event(struct stream_pos *ppos,
                        fprintf(pos->fp, ", ");
                if (pos->print_names)
                        fprintf(pos->fp, "event.fields = ");
-               fprintf(pos->fp, " ");
                ret = generic_rw(ppos, &event_class->fields->p);
                if (ret)
                        goto error;
This page took 0.023523 seconds and 4 git commands to generate.