Improve lttng add-context message output
[lttng-tools.git] / src / bin / lttng / commands / add_context.c
index a7ab4268ac5401805d83d675639962d834f0fb50..2f3bce1f5bed2ccffc872a699f1cd8b8ac486e10 100644 (file)
@@ -67,6 +67,7 @@ enum context_type {
        CONTEXT_VTID         = 7,
        CONTEXT_PPID         = 8,
        CONTEXT_VPPID        = 9,
+       CONTEXT_PTHREAD_ID   = 10,
 };
 
 /*
@@ -205,6 +206,7 @@ const struct ctx_opts {
        { "nice", CONTEXT_NICE },
        { "vpid", CONTEXT_VPID },
        { "tid", CONTEXT_TID },
+       { "pthread_id", CONTEXT_PTHREAD_ID },
        { "vtid", CONTEXT_VTID },
        { "ppid", CONTEXT_PPID },
        { "vppid", CONTEXT_VPPID },
@@ -403,14 +405,26 @@ static int add_context(char *session_name)
                ret = lttng_add_context(handle, &context, opt_event_name,
                                opt_channel_name);
                if (ret < 0) {
-                       ERR("%s: ", type->opt->symbol);
+                       ERR("%s: %s", type->opt->symbol, lttng_strerror(ret));
                        warn = 1;
                        continue;
                } else {
-                       MSG("%s context %s added to %s event in %s",
-                                       opt_kernel ? "kernel" : "UST", type->opt->symbol,
-                                       opt_event_name ? opt_event_name : "all",
-                                       opt_channel_name ? opt_channel_name : "all channels");
+                       if (opt_channel_name && opt_event_name) {
+                               MSG("%s context %s added to event %s channel %s",
+                                               opt_kernel ? "kernel" : "UST", type->opt->symbol,
+                                               opt_channel_name, opt_event_name);
+                       } else if (opt_channel_name && !opt_event_name) {
+                               MSG("%s context %s added to channel %s",
+                                               opt_kernel ? "kernel" : "UST", type->opt->symbol,
+                                               opt_channel_name);
+                       } else if (!opt_channel_name && opt_event_name) {
+                               MSG("%s context %s added to event %s",
+                                               opt_kernel ? "kernel" : "UST", type->opt->symbol,
+                                               opt_event_name);
+                       } else {
+                               MSG("%s context %s added to all channels",
+                                               opt_kernel ? "kernel" : "UST", type->opt->symbol)
+                       }
                }
        }
 
This page took 0.024229 seconds and 4 git commands to generate.