{
struct failure_context ctx = { .type = LOG_TYPE_DEBUG };
- if (event->min_log_level <= level)
+ if (level >= event->min_log_level) {
+ /* Always log when level is at least this high */
return TRUE;
+ }
- if (event->debug_level_checked_filter_counter == event_filter_replace_counter)
+ if (event->debug_level_checked_filter_counter == event_filter_replace_counter) {
+ /* Log filters haven't changed since we last checked this, so
+ we can rely on the last cached value. FIXME: this doesn't
+ work correctly if event changes and the change affects
+ whether the filters would match. */
return event->sending_debug_log;
+ }
event->debug_level_checked_filter_counter =
event_filter_replace_counter;
- if (event->forced_debug)
+ if (event->forced_debug) {
+ /* Debugging is forced for this event (and its children) */
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))
+ } else if (global_debug_log_filter != NULL &&
+ event_filter_match_source(global_debug_log_filter, event,
+ source_filename, source_linenum, &ctx)) {
+ /* log_debug filter matched */
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))
+ } else if (global_core_log_filter != NULL &&
+ event_filter_match_source(global_core_log_filter, event,
+ source_filename, source_linenum, &ctx)) {
+ /* log_core_filter matched */
event->sending_debug_log = TRUE;
- else
+ } else {
event->sending_debug_log = FALSE;
+ }
return event->sending_debug_log;
}
event_send_abort(_tmp_event); \
} STMT_END
-/* Returns TRUE if debug event should be sent (either logged or sent to
- stats). */
+/* Returns TRUE if event should be logged. Typically event_want_debug_log()
+ could be used in deciding whether to build an expensive debug log message
+ (e.g. requires extra disk IO). Note that if this is used, the actual
+ event being sent won't be matched against event filters because it's never
+ called. The result of the check is cached in the event, so repeated calls
+ are efficient. */
bool event_want_log_level(struct event *event, enum log_type level,
const char *source_filename,
unsigned int source_linenum);
#define event_want_log_level(_event, level) event_want_log_level((_event), (level), __FILE__, __LINE__)
#define event_want_debug_log(_event) event_want_log_level((_event), LOG_TYPE_DEBUG)
+/* Returns TRUE if event should be processed (for logging or sending to stats).
+ The logging is checked with event_want_log_level() with the same caching
+ behavior. */
bool event_want_level(struct event *event, enum log_type level,
const char *source_filename,
unsigned int source_linenum);
event_log_message_callback_t *log_message_callback;
void *log_message_callback_context;
ARRAY(struct event_pointer) pointers;
+ /* If the event's log level is at least this high, log it. If it's
+ lower, check for debug log filters etc. */
enum log_type min_log_level;
+
bool log_prefix_from_system_pool:1;
bool log_prefix_replace:1;
bool passthrough:1;
it allow quickly finding which of the otherwise identical syscalls in the
code generated the error. */
struct event *event_set_always_log_source(struct event *event);
-/* Set minimum log level for the event */
+/* Set minimum normal log level for the event. By default events with INFO
+ level and higher are logged. This can be used to easily hide even the INFO
+ log lines unless some verbose-setting is enabled.
+
+ Note that this functionality is mostly independent of debug logging.
+ Don't use this to enable debug log - use event_set_forced_debug() instead. */
struct event *event_set_min_log_level(struct event *event, enum log_type level);
enum log_type event_get_min_log_level(const struct event *event);