From e7ab49a85e4e5c5749949191bdeefa21a9aef9b1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 27 Mar 2019 13:36:06 -0400 Subject: [PATCH 1/1] lttng: clean-up the printout of snapshot outputs MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The printout of snapshot outputs, when they are added or listed, insistently uses "-1" and "0" to indicate that no "max-size" parameter is specified. This commit only prints the "max-size" settings when one is actually specified and changes the spelling of "max-size" to "max size". Moreover, the unit (bytes) is printed when a max-size parameter is specified on a snapshot output. This changes the output of the listing of snapshot outputs as follows. Before: $ lttng snapshot list-output Snapshot output list for session auto-20190327-133932 [1] snapshot-1: /home/jgalar/lttng-traces/auto-20190327-133932 (max-size: 0) After: $ lttng snapshot list-output Snapshot output list for session auto-20190327-133932 [1] snapshot-1: /home/jgalar/lttng-traces/auto-20190327-133932 Creating a snapshot output without a max-size no longer indicates "(max-size: -1)". Before: $ lttng snapshot add-output /tmp/keb Snapshot output successfully added for session auto-20190327-134055 [1] snapshot-1: /tmp/keb (max-size: -1) After: $ lttng snapshot add-output /tmp/keb Snapshot output successfully added for session auto-20190327-134055 [1] snapshot-1: /tmp/keb Max sizes, when specified, are printed in bytes. Before: $ lttng snapshot add-output /tmp/keb --max-size=498394 Snapshot output successfully added for session auto-20190327-134055 [1] snapshot-1: /tmp/keb (max-size: 498394) After: $ lttng snapshot add-output /tmp/keb --max-size=498394 Snapshot output successfully added for session auto-20190327-134055 [1] snapshot-1: /tmp/keb (max size: 498394 bytes) Signed-off-by: Jérémie Galarneau --- src/bin/lttng/commands/snapshot.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/bin/lttng/commands/snapshot.c b/src/bin/lttng/commands/snapshot.c index 19b28321f..b6b9faa59 100644 --- a/src/bin/lttng/commands/snapshot.c +++ b/src/bin/lttng/commands/snapshot.c @@ -179,11 +179,18 @@ static int list_output(void) } while ((s_iter = lttng_snapshot_output_list_get_next(list)) != NULL) { - MSG("%s[%" PRIu32 "] %s: %s (max-size: %" PRId64 ")", indent4, - lttng_snapshot_output_get_id(s_iter), - lttng_snapshot_output_get_name(s_iter), - lttng_snapshot_output_get_ctrl_url(s_iter), - lttng_snapshot_output_get_maxsize(s_iter)); + if (lttng_snapshot_output_get_maxsize(s_iter)) { + MSG("%s[%" PRIu32 "] %s: %s (max size: %" PRIu64 " bytes)", indent4, + lttng_snapshot_output_get_id(s_iter), + lttng_snapshot_output_get_name(s_iter), + lttng_snapshot_output_get_ctrl_url(s_iter), + lttng_snapshot_output_get_maxsize(s_iter)); + } else { + MSG("%s[%" PRIu32 "] %s: %s", indent4, + lttng_snapshot_output_get_id(s_iter), + lttng_snapshot_output_get_name(s_iter), + lttng_snapshot_output_get_ctrl_url(s_iter)); + } output_seen = 1; if (lttng_opt_mi) { ret = mi_lttng_snapshot_list_output(writer, s_iter); @@ -312,10 +319,16 @@ static int add_output(const char *url) MSG("Snapshot output successfully added for session %s", current_session_name); - MSG(" [%" PRIu32 "] %s: %s (max-size: %" PRId64 ")", - lttng_snapshot_output_get_id(output), n_ptr, - lttng_snapshot_output_get_ctrl_url(output), - lttng_snapshot_output_get_maxsize(output)); + if (opt_max_size) { + MSG(" [%" PRIu32 "] %s: %s (max size: %" PRIu64 " bytes)", + lttng_snapshot_output_get_id(output), n_ptr, + lttng_snapshot_output_get_ctrl_url(output), + lttng_snapshot_output_get_maxsize(output)); + } else { + MSG(" [%" PRIu32 "] %s: %s", + lttng_snapshot_output_get_id(output), n_ptr, + lttng_snapshot_output_get_ctrl_url(output)); + } if (lttng_opt_mi) { ret = mi_lttng_snapshot_add_output(writer, current_session_name, n_ptr, output); -- 2.34.1