Fix: pretty/print.c: print comma and space after trace name
[babeltrace.git] / plugins / text / pretty / print.c
index 25565df8b4c97a410df62b95048afe64e38ed6b1..914ae4c2d1b3b93745741974ce7c376e7dca3b58 100644 (file)
@@ -78,23 +78,25 @@ void print_field_name_equal(struct pretty_component *pretty, const char *name)
 
 static
 void print_timestamp_cycles(struct pretty_component *pretty,
-               const bt_clock_snapshot *clock_snapshot)
+               const bt_clock_snapshot *clock_snapshot, bool update_last)
 {
        uint64_t cycles;
 
        cycles = bt_clock_snapshot_get_value(clock_snapshot);
        g_string_append_printf(pretty->string, "%020" PRIu64, cycles);
 
-       if (pretty->last_cycles_timestamp != -1ULL) {
-               pretty->delta_cycles = cycles - pretty->last_cycles_timestamp;
-       }
+       if (update_last) {
+               if (pretty->last_cycles_timestamp != -1ULL) {
+                       pretty->delta_cycles = cycles - pretty->last_cycles_timestamp;
+               }
 
-       pretty->last_cycles_timestamp = cycles;
+               pretty->last_cycles_timestamp = cycles;
+       }
 }
 
 static
 void print_timestamp_wall(struct pretty_component *pretty,
-               const bt_clock_snapshot *clock_snapshot)
+               const bt_clock_snapshot *clock_snapshot, bool update_last)
 {
        int ret;
        int64_t ts_nsec = 0;    /* add configurable offset */
@@ -114,11 +116,14 @@ void print_timestamp_wall(struct pretty_component *pretty,
                return;
        }
 
-       if (pretty->last_real_timestamp != -1ULL) {
-               pretty->delta_real_timestamp = ts_nsec - pretty->last_real_timestamp;
+       if (update_last) {
+               if (pretty->last_real_timestamp != -1ULL) {
+                       pretty->delta_real_timestamp = ts_nsec - pretty->last_real_timestamp;
+               }
+
+               pretty->last_real_timestamp = ts_nsec;
        }
 
-       pretty->last_real_timestamp = ts_nsec;
        ts_sec += ts_nsec / NSEC_PER_SEC;
        ts_nsec = ts_nsec % NSEC_PER_SEC;
 
@@ -239,9 +244,9 @@ int print_event_timestamp(struct pretty_component *pretty,
                g_string_append(pretty->string, COLOR_TIMESTAMP);
        }
        if (pretty->options.print_timestamp_cycles) {
-               print_timestamp_cycles(pretty, clock_snapshot);
+               print_timestamp_cycles(pretty, clock_snapshot, true);
        } else {
-               print_timestamp_wall(pretty, clock_snapshot);
+               print_timestamp_wall(pretty, clock_snapshot, true);
        }
        if (pretty->use_colors) {
                g_string_append(pretty->string, COLOR_RST);
@@ -260,7 +265,7 @@ int print_event_timestamp(struct pretty_component *pretty,
                if (pretty->options.print_timestamp_cycles) {
                        if (pretty->delta_cycles == -1ULL) {
                                g_string_append(pretty->string,
-                                       "+??????????\?\?"); /* Not a trigraph. */
+                                       "+??????????\?\?"); /* Not a trigraph. */
                        } else {
                                g_string_append_printf(pretty->string,
                                        "+%012" PRIu64, pretty->delta_cycles);
@@ -329,8 +334,8 @@ int print_event_header(struct pretty_component *pretty,
 
                        g_string_append(pretty->string, name);
 
-                       if (!print_names) {
-                               g_string_append(pretty->string, " ");
+                       if (print_names) {
+                               g_string_append(pretty->string, ", ");
                        }
                }
        }
@@ -1214,6 +1219,7 @@ int print_discarded_elements_msg(struct pretty_component *pretty,
        bt_uuid trace_uuid;
        int64_t stream_class_id;
        int64_t stream_id;
+       const char *init_msg;
 
        /* Stream name */
        stream_name = bt_stream_get_name(stream);
@@ -1243,16 +1249,22 @@ int print_discarded_elements_msg(struct pretty_component *pretty,
 
        /* Format message */
        g_string_assign(pretty->string, "");
+
+       if (count == UINT64_C(-1)) {
+               init_msg = "Tracer may have discarded";
+       } else {
+               init_msg = "Tracer discarded";
+       }
+
        g_string_append_printf(pretty->string,
-               "%s%sWARNING%s%s: Tracer discarded ",
+               "%s%sWARNING%s%s: %s ",
                bt_common_color_fg_yellow(),
                bt_common_color_bold(),
                bt_common_color_reset(),
-               bt_common_color_fg_yellow());
+               bt_common_color_fg_yellow(), init_msg);
 
        if (count == UINT64_C(-1)) {
-               g_string_append_printf(pretty->string, "a number of %ss",
-                       elem_type);
+               g_string_append_printf(pretty->string, "%ss", elem_type);
        } else {
                g_string_append_printf(pretty->string,
                        "%" PRIu64 " %s%s", count, elem_type,
@@ -1261,9 +1273,9 @@ int print_discarded_elements_msg(struct pretty_component *pretty,
 
        if (begin_clock_snapshot && end_clock_snapshot) {
                g_string_append(pretty->string, " between [");
-               print_timestamp_wall(pretty, begin_clock_snapshot);
+               print_timestamp_wall(pretty, begin_clock_snapshot, false);
                g_string_append(pretty->string, "] and [");
-               print_timestamp_wall(pretty, end_clock_snapshot);
+               print_timestamp_wall(pretty, end_clock_snapshot, false);
                g_string_append(pretty->string, "]");
        } else {
                g_string_append(pretty->string, "(unknown time range)");
This page took 0.029875 seconds and 4 git commands to generate.