From 05f562fdc301919dc8333bbe86801dab346d41a3 Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Mon, 19 Dec 2011 14:49:59 +0100 Subject: [PATCH] logging: use SCLogDebug instead of printf This patch uses SCLogDebug instead of printf to enable filtering of the log message by the log filtering option. --- src/detect-uricontent.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/detect-uricontent.c b/src/detect-uricontent.c index 1246a35909..9384184da4 100644 --- a/src/detect-uricontent.c +++ b/src/detect-uricontent.c @@ -315,11 +315,20 @@ DetectContentData *DoDetectUricontentSetup (char * contentstr) #ifdef DEBUG if (SCLogDebugEnabled()) { - for (i = 0; i < x; i++) { - if (isprint(str[i])) printf("%c", str[i]); - else printf("\\x%02u", str[i]); + char *prstr = SCMalloc(3 * x); + char onechar[3]; + memset(prstr, 0, 3 * x); + if (prstr != NULL) { + for (i = 0; i < x; i++) { + if (isprint(str[i])) + snprintf(onechar, 3, "%c", str[i]); + else + snprintf(onechar, 3, "\\x%02u", str[i]); + strlcat(prstr, onechar, 3 * x); + } + SCLogDebug("\"%s\"", prstr); + SCFree(prstr); } - printf("\n"); } #endif