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:58:49 +0000 (14:58 -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 be2e275f8369bb63a20e2124b8dc5ed0f24ffb06..ac123cdbc20732eb96cdc0b9145ab5586608b14f 100644 (file)
@@ -717,7 +717,7 @@ static char *set_jul_filter(const char *filter, struct lttng_event *ev)
                }
                if (err < 0) {
                        PERROR("asprintf");
-                       goto end;
+                       goto error;
                }
        }
 
@@ -731,23 +731,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.028027 seconds and 4 git commands to generate.