From: Sergey Kitov Date: Mon, 19 Mar 2018 09:20:58 +0000 (+0200) Subject: lib: Add event_want_debug and event_want_debug_log macros X-Git-Tag: 2.3.3.rc1~185 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c99dc72e2f00e0220c4922a0325115a5247e7fe3;p=thirdparty%2Fdovecot%2Fcore.git lib: Add event_want_debug and event_want_debug_log macros --- diff --git a/src/lib/event-log.c b/src/lib/event-log.c index 7f4074e76d..d73c8cd1e3 100644 --- a/src/lib/event-log.c +++ b/src/lib/event-log.c @@ -108,31 +108,33 @@ void event_log(struct event *event, const struct event_log_params *params, va_end(args); } -static bool -event_want_debug_log(struct event *event, const char *source_filename, +#undef event_want_debug_log +bool event_want_debug_log(struct event *event, const char *source_filename, unsigned int source_linenum) { struct failure_context ctx = { .type = LOG_TYPE_DEBUG }; if (event->forced_debug) - return TRUE; - - if (global_debug_log_filter != NULL && - event_filter_match_source(global_debug_log_filter, event, - source_filename, source_linenum, &ctx)) - return TRUE; - if (global_core_log_filter != NULL && - event_filter_match_source(global_core_log_filter, event, - source_filename, source_linenum, &ctx)) - return TRUE; - return FALSE; + event->sending_debug_log = TRUE; + + else if (global_debug_log_filter != NULL && + event_filter_match_source(global_debug_log_filter, event, + source_filename, source_linenum, &ctx)) + event->sending_debug_log = TRUE; + else if (global_core_log_filter != NULL && + event_filter_match_source(global_core_log_filter, event, + source_filename, source_linenum, &ctx)) + event->sending_debug_log = TRUE; + else + event->sending_debug_log = FALSE; + return event->sending_debug_log; } +#undef event_want_debug bool event_want_debug(struct event *event, const char *source_filename, unsigned int source_linenum) { - event->sending_debug_log = - event_want_debug_log(event, source_filename, source_linenum); + (void)event_want_debug_log(event, source_filename, source_linenum); if (event->sending_debug_log) return TRUE; diff --git a/src/lib/event-log.h b/src/lib/event-log.h index 8813e86a88..2da89bc9ae 100644 --- a/src/lib/event-log.h +++ b/src/lib/event-log.h @@ -31,15 +31,20 @@ void e_debug(struct event *event, const char *fmt, ...) ATTR_FORMAT(4, 5); #define e_debug(_event, ...) STMT_START { \ struct event *_tmp_event = (_event); \ - if (event_want_debug(_tmp_event, __FILE__, __LINE__)) \ + if (event_want_debug(_tmp_event)) \ e_debug(_tmp_event, __FILE__, __LINE__, __VA_ARGS__); \ else \ event_send_abort(_tmp_event); \ } STMT_END /* Returns TRUE if debug event should be sent (either logged or sent to stats). */ +bool event_want_debug_log(struct event *event, const char *source_filename, + unsigned int source_linenum); +#define event_want_debug_log(_event) event_want_debug_log((_event), __FILE__, __LINE__) + bool event_want_debug(struct event *event, const char *source_filename, unsigned int source_linenum); +#define event_want_debug(_event) event_want_debug((_event), __FILE__, __LINE__) void event_log(struct event *event, const struct event_log_params *params, const char *fmt, ...)