]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Add mailbox_set_critical() and mail_set_critical()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 22 Nov 2017 10:16:46 +0000 (12:16 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 22 Nov 2017 16:36:42 +0000 (18:36 +0200)
These add the mailbox vname and mail UID to the log prefix and then call
mail_storage_set_critical().

src/lib-storage/mail-storage-private.h
src/lib-storage/mail-storage.c

index 78e307f18ca39f9d9603c136b5579cefaa10e9dc..b80bbd9f7ab22ac505dff6c6a66194f0286b2aea 100644 (file)
@@ -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,
index ff0de66e2134353124b38dba9a75bde2e4a6ea95..e20c79d54728c40dc5950f952576cfd0e04b128d 100644 (file)
@@ -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)
 {