summaryrefslogtreecommitdiff
path: root/lib/log_filter.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2021-04-10 21:51:48 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2021-06-18 21:05:21 +0200
commit8b94cb4388d62ad341ff352266dd5d91780e4eec (patch)
tree26e303a99b7ae7a7cfb84e8e75d2d31dbc932020 /lib/log_filter.c
parent243ff228a9b4b680c2c405320634f4f72c65191c (diff)
lib: include `\n` in zlog_msg_text()
Since the file targets append one anyway, save them some extra work. syslog can use `%.*s` since it's "forced" printf by API anyway. Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'lib/log_filter.c')
-rw-r--r--lib/log_filter.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/log_filter.c b/lib/log_filter.c
index 721e57a628..f01497dead 100644
--- a/lib/log_filter.c
+++ b/lib/log_filter.c
@@ -111,13 +111,14 @@ int zlog_filter_dump(char *buf, size_t max_size)
return len;
}
-static int search_buf(const char *buf)
+static int search_buf(const char *buf, size_t len)
{
char *found = NULL;
frr_with_mutex(&logfilterlock) {
for (int i = 0; i < zlog_filter_count; i++) {
- found = strstr(buf, zlog_filters[i]);
+ found = memmem(buf, len, zlog_filters[i],
+ strlen(zlog_filters[i]));
if (found != NULL)
return 0;
}
@@ -131,12 +132,15 @@ static void zlog_filterfile_fd(struct zlog_target *zt, struct zlog_msg *msgs[],
{
struct zlog_msg *msgfilt[nmsgs];
size_t i, o = 0;
+ const char *text;
+ size_t text_len;
for (i = 0; i < nmsgs; i++) {
- if (zlog_msg_prio(msgs[i]) >= LOG_DEBUG
- && search_buf(zlog_msg_text(msgs[i], NULL)) < 0)
- continue;
-
+ if (zlog_msg_prio(msgs[i]) >= LOG_DEBUG) {
+ text = zlog_msg_text(msgs[i], &text_len);
+ if (search_buf(text, text_len) < 0)
+ continue;
+ }
msgfilt[o++] = msgs[i];
}