From fd948396718b98fc9da7b66aaf17942074193afc Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Sat, 13 May 2017 18:51:10 -0400 Subject: [PATCH] cli/babeltrace.c: improve main loop's logging MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- cli/babeltrace.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/cli/babeltrace.c b/cli/babeltrace.c index 00dc4985a..d51229ba5 100644 --- a/cli/babeltrace.c +++ b/cli/babeltrace.c @@ -1555,6 +1555,31 @@ end: return ret; } +static inline +const char *bt_graph_status_str(enum bt_graph_status status) +{ + switch (status) { + case BT_GRAPH_STATUS_CANCELED: + return "BT_GRAPH_STATUS_CANCELED"; + case BT_GRAPH_STATUS_AGAIN: + return "BT_GRAPH_STATUS_AGAIN"; + case BT_GRAPH_STATUS_END: + return "BT_GRAPH_STATUS_END"; + case BT_GRAPH_STATUS_OK: + return "BT_GRAPH_STATUS_OK"; + case BT_GRAPH_STATUS_ALREADY_IN_A_GRAPH: + return "BT_GRAPH_STATUS_ALREADY_IN_A_GRAPH"; + case BT_GRAPH_STATUS_INVALID: + return "BT_GRAPH_STATUS_INVALID"; + case BT_GRAPH_STATUS_NO_SINK: + return "BT_GRAPH_STATUS_NO_SINK"; + case BT_GRAPH_STATUS_ERROR: + return "BT_GRAPH_STATUS_ERROR"; + default: + return "(unknown)"; + } +} + static int cmd_run(struct bt_config *cfg) { @@ -1592,17 +1617,18 @@ int cmd_run(struct bt_config *cfg) while (true) { enum bt_graph_status graph_status = bt_graph_run(ctx.graph); + BT_LOGV("bt_graph_run() returned: status=%s", + bt_graph_status_str(graph_status)); + switch (graph_status) { case BT_GRAPH_STATUS_OK: break; case BT_GRAPH_STATUS_CANCELED: - BT_LOGI("Graph was canceled by user: status=%d", - graph_status); + BT_LOGI_STR("Graph was canceled by user."); goto error; case BT_GRAPH_STATUS_AGAIN: if (bt_graph_is_canceled(ctx.graph)) { - BT_LOGI("Graph was canceled by user: status=%d", - graph_status); + BT_LOGI_STR("Graph was canceled by user."); goto error; } -- 2.34.1