Mercurial > dovecot > core-2.2
changeset 21566:7dfa73aba5f6
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.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Wed, 15 Feb 2017 23:32:52 +0200 |
parents | c6ed855ff6c9 |
children | 8004757eeee0 |
files | src/plugins/mail-log/mail-log-plugin.c |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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; }