diff --git a/src/util-debug-filters.c b/src/util-debug-filters.c index bcb3f4701d..0cf259d13c 100644 --- a/src/util-debug-filters.c +++ b/src/util-debug-filters.c @@ -18,6 +18,12 @@ extern int sc_log_module_initialized; extern int sc_log_module_cleaned; +/* used to indicate if any FG filters are registered */ +int sc_log_fg_filters_present = 0; + +/* used to indicate if any FD filters are registered */ +int sc_log_fd_filters_present = 0; + /** * \brief Holds the fine-grained filters */ @@ -306,6 +312,8 @@ static inline int SCLogAddFGFilter(const char *file, const char *function, done: mutex_unlock(&sc_log_fg_filters_m[listtype]); + sc_log_fg_filters_present = 1; + return 0; } @@ -860,6 +868,7 @@ int SCLogAddFDFilter(const char *function) } mutex_unlock(&sc_log_fd_filters_m); + sc_log_fd_filters_present = 1; return 0; } @@ -943,6 +952,9 @@ int SCLogRemoveFDFilter(const char *function) mutex_unlock(&sc_log_fd_filters_m); + if (sc_log_fd_filters == NULL) + sc_log_fd_filters_present = 0; + return 0; } diff --git a/src/util-debug-filters.h b/src/util-debug-filters.h index ab4c41d4b8..0636c6417e 100644 --- a/src/util-debug-filters.h +++ b/src/util-debug-filters.h @@ -66,6 +66,12 @@ typedef struct SCLogFDFilter_ { struct SCLogFDFilter_ *next; } SCLogFDFilter; + +extern int sc_log_fg_filters_present; + +extern int sc_log_fd_filters_present; + + int SCLogAddFGFilterWL(const char *, const char *, int); int SCLogAddFGFilterBL(const char *, const char *, int); diff --git a/src/util-debug.c b/src/util-debug.c index 0d2c419866..fc2aafa3c1 100644 --- a/src/util-debug.c +++ b/src/util-debug.c @@ -274,13 +274,15 @@ SCError SCLogMessage(SCLogLevel log_level, char **msg, const char *file, return SC_LOG_MODULE_NOT_INIT; } - if (SCLogMatchFGFilterWL(file, function, line) != 1) - return SC_LOG_FG_FILTER_MATCH_FAILED; + if (sc_log_fg_filters_present == 1) { + if (SCLogMatchFGFilterWL(file, function, line) != 1) + return SC_LOG_FG_FILTER_MATCH_FAILED; - if (SCLogMatchFGFilterBL(file, function, line) != 1) - return SC_LOG_FG_FILTER_MATCH_FAILED; + if (SCLogMatchFGFilterBL(file, function, line) != 1) + return SC_LOG_FG_FILTER_MATCH_FAILED; + } - if (SCLogMatchFDFilter(function) != 1) + if (sc_log_fd_filters_present == 1 && SCLogMatchFDFilter(function) != 1) return SC_LOG_FG_FILTER_MATCH_FAILED; while ( (temp_fmt = index(temp_fmt, SC_LOG_FMT_PREFIX)) ) {