Fix: fail gracefully on --exclude on unsupported domains
[lttng-tools.git] / src / bin / lttng / commands / enable_events.c
index f1d04581fd9f5eb05532f6667c84eddd9e6d1faa..c13232a5aaf8fe14a2cf8a419e6c5e607f3e9c4e 100644 (file)
@@ -101,7 +101,7 @@ static struct poptOption long_options[] = {
  */
 static void usage(FILE *ofp)
 {
-       fprintf(ofp, "usage: lttng enable-event NAME[,NAME2,...] [-k|-u] [OPTIONS] \n");
+       fprintf(ofp, "usage: lttng enable-event NAME[,NAME2,...] (-k | -u | -j | -l | -p) [OPTIONS] \n");
        fprintf(ofp, "\n");
        fprintf(ofp, "Options:\n");
        fprintf(ofp, "  -h, --help               Show this help\n");
@@ -134,7 +134,7 @@ static void usage(FILE *ofp)
        fprintf(ofp, "\n");
        fprintf(ofp, "    --loglevel name\n");
        fprintf(ofp, "                           Tracepoint loglevel range from 0 to loglevel.\n");
-       fprintf(ofp, "                           For JUL/LOG4j domain, see the table below for the range values.\n");
+       fprintf(ofp, "                           For JUL/LOG4j/Python domains, see the table below for the range values.\n");
        fprintf(ofp, "    --loglevel-only name\n");
        fprintf(ofp, "                           Tracepoint loglevel (only this loglevel)\n");
        fprintf(ofp, "\n");
@@ -632,7 +632,7 @@ int check_exclusion_subsets(const char *event_name,
                                        goto error;
                                }
                                new_exclusion_list = realloc(exclusion_list,
-                                       sizeof(char **) * (exclusion_count + 1));
+                                       sizeof(char *) * (exclusion_count + 1));
                                if (!new_exclusion_list) {
                                        PERROR("realloc");
                                        free(string);
@@ -726,10 +726,22 @@ static int enable_events(char *session_name)
                goto error;
        }
 
-       if (opt_kernel && opt_exclude) {
-               ERR("Event name exclusions are not yet implemented for kernel events");
-               ret = CMD_ERROR;
-               goto error;
+       if (opt_exclude) {
+               switch (dom.type) {
+               case LTTNG_DOMAIN_KERNEL:
+               case LTTNG_DOMAIN_JUL:
+               case LTTNG_DOMAIN_LOG4J:
+               case LTTNG_DOMAIN_PYTHON:
+                       ERR("Event name exclusions are not yet implemented for %s events",
+                                       get_domain_str(dom.type));
+                       ret = CMD_ERROR;
+                       goto error;
+               case LTTNG_DOMAIN_UST:
+                       /* Exclusions supported */
+                       break;
+               default:
+                       assert(0);
+               }
        }
 
        channel_name = opt_channel_name;
@@ -781,8 +793,10 @@ static int enable_events(char *session_name)
                                assert(opt_userspace || opt_jul || opt_log4j || opt_python);
                                if (opt_userspace) {
                                        ev.loglevel = -1;
-                               } else if (opt_jul || opt_log4j) {
+                               } else if (opt_jul) {
                                        ev.loglevel = LTTNG_LOGLEVEL_JUL_ALL;
+                               } else if (opt_log4j) {
+                                       ev.loglevel = LTTNG_LOGLEVEL_LOG4J_ALL;
                                } else if (opt_python) {
                                        ev.loglevel = LTTNG_LOGLEVEL_PYTHON_DEBUG;
                                }
This page took 0.026311 seconds and 5 git commands to generate.