lttng: add-trigger: print generated trigger name
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 30 Jun 2021 22:41:24 +0000 (18:41 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 30 Jun 2021 22:41:24 +0000 (18:41 -0400)
Print the generated trigger name when `add-trigger` succeeds. Also,
no message is emited when a trigger is successfully registered as
the command will print an error message if any error occurs.

There is also no need to parrot the trigger's name if it was specified
by the user.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9607fbd358298b036bd533834143eb5e9d185cd0

src/bin/lttng/commands/add_trigger.c

index e7809dc521362408cc2df6b3ed58dddc5f55d2a8..583dd1903400dccca12d89ec7ee92cad380a7ac7 100644 (file)
@@ -2406,9 +2406,22 @@ int cmd_add_trigger(int argc, const char **argv)
                if (ret_code != LTTNG_OK) {
                        goto error;
                }
+       } else {
+               if (!name) {
+                       const char *returned_trigger_name;
+                       const enum lttng_trigger_status trigger_status =
+                                       lttng_trigger_get_name(trigger,
+                                                       &returned_trigger_name);
+
+                       if (trigger_status != LTTNG_TRIGGER_STATUS_OK) {
+                               WARN("Failed to retrieve the name generated for the added trigger.");
+                       } else {
+                               MSG("Added trigger '%s'.",
+                                               returned_trigger_name);
+                       }
+               }
        }
 
-       MSG("Trigger registered successfully.");
        ret = 0;
 
        goto end;
This page took 0.027868 seconds and 4 git commands to generate.