From: Timo Sirainen Date: Wed, 22 Nov 2017 10:16:46 +0000 (+0200) Subject: lib-storage: Add mailbox_set_critical() and mail_set_critical() X-Git-Tag: 2.3.0.rc1~417 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4e3b79ac7787b1a867514a6ac3d1b623b72a26c6;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Add mailbox_set_critical() and mail_set_critical() These add the mailbox vname and mail UID to the log prefix and then call mail_storage_set_critical(). --- diff --git a/src/lib-storage/mail-storage-private.h b/src/lib-storage/mail-storage-private.h index 78e307f18c..b80bbd9f7a 100644 --- a/src/lib-storage/mail-storage-private.h +++ b/src/lib-storage/mail-storage-private.h @@ -726,6 +726,10 @@ void mail_storage_set_error(struct mail_storage *storage, enum mail_error error, const char *string); void mail_storage_set_critical(struct mail_storage *storage, const char *fmt, ...) ATTR_FORMAT(2, 3); +void mailbox_set_critical(struct mailbox *box, + const char *fmt, ...) ATTR_FORMAT(2, 3); +void mail_set_critical(struct mail *mail, + const char *fmt, ...) ATTR_FORMAT(2, 3); void mail_storage_set_internal_error(struct mail_storage *storage); void mailbox_set_index_error(struct mailbox *box); void mail_storage_set_index_error(struct mail_storage *storage, diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index ff0de66e21..e20c79d547 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -565,6 +565,35 @@ void mail_storage_set_critical(struct mail_storage *storage, i_free(old_internal_error); } +void mailbox_set_critical(struct mailbox *box, const char *fmt, ...) +{ + va_list va; + + va_start(va, fmt); + T_BEGIN { + mail_storage_set_critical(box->storage, "Mailbox %s: %s", + box->vname, t_strdup_vprintf(fmt, va)); + } T_END; + va_end(va); +} + +void mail_set_critical(struct mail *mail, const char *fmt, ...) +{ + va_list va; + + va_start(va, fmt); + T_BEGIN { + if (mail->saving) { + mailbox_set_critical(mail->box, "Saving mail: %s", + t_strdup_vprintf(fmt, va)); + } else { + mailbox_set_critical(mail->box, "UID=%u: %s", + mail->uid, t_strdup_vprintf(fmt, va)); + } + } T_END; + va_end(va); +} + const char *mail_storage_get_last_internal_error(struct mail_storage *storage, enum mail_error *error_r) {