From: Aki Tuomi Date: Tue, 11 Dec 2018 13:46:05 +0000 (+0200) Subject: lib: event - Add min_log_level X-Git-Tag: 2.3.9~957 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0418a48fd8be6ebc70c987d1d2cc58dfa8aedafb;p=thirdparty%2Fdovecot%2Fcore.git lib: event - Add min_log_level Determines minimum severity to log for this event --- diff --git a/src/lib/lib-event-private.h b/src/lib/lib-event-private.h index 63c805af5e..7b62e25421 100644 --- a/src/lib/lib-event-private.h +++ b/src/lib/lib-event-private.h @@ -14,6 +14,7 @@ struct event { char *log_prefix; event_log_prefix_callback_t *log_prefix_callback; void *log_prefix_callback_context; + enum log_type min_log_level; bool log_prefix_from_system_pool:1; bool log_prefix_replace:1; bool passthrough:1; diff --git a/src/lib/lib-event.c b/src/lib/lib-event.c index ab97a97193..f78d9e88aa 100644 --- a/src/lib/lib-event.c +++ b/src/lib/lib-event.c @@ -44,6 +44,7 @@ static void event_copy_parent_defaults(struct event *event, { event->always_log_source = parent->always_log_source; event->passthrough = parent->passthrough; + event->min_log_level = parent->min_log_level; event->forced_debug = parent->forced_debug; } @@ -130,6 +131,7 @@ struct event *event_create(struct event *parent, const char *source_filename, event->id = ++event_id_counter; event->pool = pool; event->tv_created_ioloop = ioloop_timeval; + event->min_log_level = LOG_TYPE_INFO; if (gettimeofday(&event->tv_created, NULL) < 0) i_panic("gettimeofday() failed: %m"); event->source_filename = p_strdup(pool, source_filename); @@ -349,6 +351,17 @@ struct event *event_set_always_log_source(struct event *event) return event; } +struct event *event_set_min_log_level(struct event *event, enum log_type level) +{ + event->min_log_level = level; + return event; +} + +enum log_type event_get_min_log_level(const struct event *event) +{ + return event->min_log_level; +} + struct event_category *event_category_find_registered(const char *name) { struct event_category *const *catp; diff --git a/src/lib/lib-event.h b/src/lib/lib-event.h index e0c4143495..d72a8ce366 100644 --- a/src/lib/lib-event.h +++ b/src/lib/lib-event.h @@ -185,6 +185,9 @@ event_set_source(struct event *event, const char *filename, 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 */ +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); /* Add NULL-terminated list of categories to the event. The categories pointer doesn't need to stay valid afterwards, but the event_category structs