Clean-up: run clang-format 14 on the tree
[lttng-tools.git] / src / bin / lttng / commands / enable_channels.cpp
index c302132fbca258e4e5234c679ef4073a38612092..4e5f2eb15534147b28ea05233600862652d3408e 100644 (file)
@@ -9,6 +9,7 @@
 #include "../command.hpp"
 #include "../utils.hpp"
 
+#include <common/lttng-kernel.hpp>
 #include <common/mi-lttng.hpp>
 #include <common/sessiond-comm/sessiond-comm.hpp>
 #include <common/utils.hpp>
@@ -283,15 +284,13 @@ static int enable_channel(char *session_name, char *channel_list)
 
                ret = lttng_enable_channel(handle, channel);
                if (ret < 0) {
+                       bool msg_already_printed = false;
+
                        success = 0;
                        switch (-ret) {
                        case LTTNG_ERR_KERN_CHAN_EXIST:
                        case LTTNG_ERR_UST_CHAN_EXIST:
                        case LTTNG_ERR_CHAN_EXIST:
-                               WARN("Channel %s: %s (session %s)",
-                                    channel_name,
-                                    lttng_strerror(ret),
-                                    session_name);
                                warn = 1;
                                break;
                        case LTTNG_ERR_INVALID_CHANNEL_NAME:
@@ -299,18 +298,27 @@ static int enable_channel(char *session_name, char *channel_list)
                                    "Channel names may not start with '.', and "
                                    "may not contain '/'.",
                                    channel_name);
+                               msg_already_printed = true;
                                error = 1;
                                break;
                        default:
-                               ERR("Channel %s: %s (session %s)",
-                                   channel_name,
-                                   lttng_strerror(ret),
-                                   session_name);
                                error = 1;
                                break;
                        }
+
+                       if (!msg_already_printed) {
+                               LOG(error ? PRINT_ERR : PRINT_WARN,
+                                   "Failed to enable channel `%s` under session `%s`: %s",
+                                   channel_name,
+                                   session_name,
+                                   lttng_strerror(ret));
+                       }
+
+                       if (opt_kernel) {
+                               print_kernel_tracer_status_error();
+                       }
                } else {
-                       MSG("%s channel %s enabled for session %s",
+                       MSG("%s channel `%s` enabled for session `%s`",
                            lttng_domain_type_str(dom.type),
                            channel_name,
                            session_name);
This page took 0.023329 seconds and 4 git commands to generate.