# HG changeset patch # User Timo Sirainen # Date 1487194372 -7200 # Node ID 7dfa73aba5f640464de86abf98a28bc55cc76795 # Parent c6ed855ff6c9add0dba3c80035a6224e045f23bc mail-log: Add mail_log_cached_only setting. If enabled, everything except "save" event will log only the fields that can be looked up from cache. This improves performance if some of the fields aren't cached and it's not a strict requirement to log them. diff -r c6ed855ff6c9 -r 7dfa73aba5f6 src/plugins/mail-log/mail-log-plugin.c --- a/src/plugins/mail-log/mail-log-plugin.c Wed Feb 15 13:46:06 2017 -0500 +++ b/src/plugins/mail-log/mail-log-plugin.c Wed Feb 15 23:32:52 2017 +0200 @@ -78,6 +78,7 @@ enum mail_log_field fields; enum mail_log_event events; + bool cached_only; }; struct mail_log_message { @@ -165,6 +166,9 @@ str = mail_user_plugin_getenv(user, "mail_log_events"); muser->events = str == NULL ? MAIL_LOG_DEFAULT_EVENTS : mail_log_parse_events(str); + + muser->cached_only = + mail_user_plugin_getenv(user, "mail_log_cached_only") != NULL; } static void mail_log_append_mailbox_name(string_t *str, struct mail *mail) @@ -333,7 +337,12 @@ } T_BEGIN { + enum mail_lookup_abort orig_lookup_abort = mail->lookup_abort; + + if (event != MAIL_LOG_EVENT_SAVE && muser->cached_only) + mail->lookup_abort = MAIL_LOOKUP_ABORT_NOT_IN_CACHE; mail_log_append_mail_message_real(ctx, mail, event, desc); + mail->lookup_abort = orig_lookup_abort; } T_END; }