]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: event - Add min_log_level
authorAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 11 Dec 2018 13:46:05 +0000 (15:46 +0200)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Thu, 10 Jan 2019 11:02:44 +0000 (13:02 +0200)
Determines minimum severity to log for this event

src/lib/lib-event-private.h
src/lib/lib-event.c
src/lib/lib-event.h

index 63c805af5e5b3e376309870ce99c559ccec4e626..7b62e254217d21280a4c95de6519ee6a6c4bff80 100644 (file)
@@ -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;
index ab97a971937013359645792ef70652debcf6b60c..f78d9e88aa6fb86ad1e5ccd43f1eaec189ec7362 100644 (file)
@@ -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;
index e0c414349544fd1746d6fb5bd1fdd7c01febd359..d72a8ce36637b7a6323e6a67b1de701f25ee12d1 100644 (file)
@@ -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