]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Add event_want_debug and event_want_debug_log macros
authorSergey Kitov <sergey.kitov@open-xchange.com>
Mon, 19 Mar 2018 09:20:58 +0000 (11:20 +0200)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 7 Aug 2018 11:10:07 +0000 (14:10 +0300)
src/lib/event-log.c
src/lib/event-log.h

index 7f4074e76dc943e67567fdab4c9ab05d67d78b2d..d73c8cd1e3919756e9cc9799b5fd31d237dd4329 100644 (file)
@@ -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;
 
index 8813e86a88aca72b27483761ffad0402264648ee..2da89bc9ae99caf5188c432d92bcabfe2071c54c 100644 (file)
@@ -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, ...)