Fix: logger name dropped from filter condition when loglevels are used
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 10 Jul 2014 18:24:59 +0000 (14:24 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Thu, 10 Jul 2014 18:56:21 +0000 (14:56 -0400)
This fix ensures that the loglevel expression is appended to the filter
expression and does not overwrite the current one.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/lib/lttng-ctl/lttng-ctl.c

index d2f6799e11a070031805f09774e33b137c33d38c..01572dc94dc2aa873d58ece215734a0ffcb8485c 100644 (file)
@@ -710,7 +710,7 @@ static char *set_jul_filter(const char *filter, struct lttng_event *ev)
                }
                if (err < 0) {
                        PERROR("asprintf");
-                       goto end;
+                       goto error;
                }
        }
 
@@ -724,23 +724,30 @@ static char *set_jul_filter(const char *filter, struct lttng_event *ev)
                        op = "==";
                }
 
-               if (filter) {
-                       err = asprintf(&jul_filter, "%s && int_loglevel %s %d", filter, op,
+               if (filter || jul_filter) {
+                       char *new_filter;
+
+                       err = asprintf(&new_filter, "%s && int_loglevel %s %d",
+                                       jul_filter ? jul_filter : filter, op,
                                        ev->loglevel);
+                       if (jul_filter) {
+                               free(jul_filter);
+                       }
+                       jul_filter = new_filter;
                } else {
                        err = asprintf(&jul_filter, "int_loglevel %s %d", op,
                                        ev->loglevel);
                }
                if (err < 0) {
                        PERROR("asprintf");
-                       free(jul_filter);
-                       jul_filter = NULL;
-                       goto end;
+                       goto error;
                }
        }
 
-end:
        return jul_filter;
+error:
+       free(jul_filter);
+       return NULL;
 }
 
 /*
This page took 0.027211 seconds and 4 git commands to generate.