From: Jérémie Galarneau Date: Thu, 10 Jul 2014 18:24:59 +0000 (-0400) Subject: Fix: logger name dropped from filter condition when loglevels are used X-Git-Tag: v2.6.0-rc1~154 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=6a556f7b1ed1560da4e4e190ef6989670ddb8938;p=lttng-tools.git Fix: logger name dropped from filter condition when loglevels are used 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 Signed-off-by: David Goulet --- diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index d2f6799e1..01572dc94 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -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; } /*