]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
plugins: replace "if(mail_debug){i_debug}" with "e_debug"
authorSergey Kitov <sergey.kitov@open-xchange.com>
Tue, 20 Mar 2018 09:20:44 +0000 (11:20 +0200)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 7 Aug 2018 11:10:07 +0000 (14:10 +0300)
22 files changed:
src/plugins/acl/acl-backend.c
src/plugins/acl/acl-lookup-dict.c
src/plugins/acl/acl-mailbox-list.c
src/plugins/acl/acl-storage.c
src/plugins/apparmor/apparmor-plugin.c
src/plugins/charset-alias/charset-alias-plugin.c
src/plugins/expire/expire-plugin.c
src/plugins/fts/fts-parser-tika.c
src/plugins/fts/fts-storage.c
src/plugins/lazy-expunge/lazy-expunge-plugin.c
src/plugins/mail-crypt/mail-crypt-plugin.c
src/plugins/mail-crypt/mail-crypt-userenv.c
src/plugins/mail-filter/mail-filter-plugin.c
src/plugins/notify-status/notify-status-plugin.c
src/plugins/pop3-migration/pop3-migration-plugin.c
src/plugins/push-notification/push-notification-drivers.c
src/plugins/quota-clone/quota-clone-plugin.c
src/plugins/quota/quota-storage.c
src/plugins/replication/replication-plugin.c
src/plugins/trash/trash-plugin.c
src/plugins/virtual/virtual-storage.c
src/plugins/welcome/welcome-plugin.c

index 026aef59c5df7307b5ef289a2bab51a1a438ecf6..0514dc736f9cd6074ac8043b2936a00b7c0a4951 100644 (file)
@@ -40,11 +40,9 @@ acl_backend_init(const char *data, struct mailbox_list *list,
        struct acl_backend *backend;
        unsigned int i, group_count;
 
-       if (user->mail_debug) {
-               i_debug("acl: initializing backend with data: %s", data);
-               i_debug("acl: acl username = %s", acl_username);
-               i_debug("acl: owner = %d", owner ? 1 : 0);
-       }
+       e_debug(user->event, "acl: initializing backend with data: %s", data);
+       e_debug(user->event, "acl: acl username = %s", acl_username);
+       e_debug(user->event, "acl: owner = %d", owner ? 1 : 0);
 
        group_count = str_array_length(groups);
 
@@ -70,8 +68,7 @@ acl_backend_init(const char *data, struct mailbox_list *list,
                        p_new(backend->pool, const char *, group_count);
                for (i = 0; i < group_count; i++) {
                        backend->groups[i] = p_strdup(backend->pool, groups[i]);
-                       if (user->mail_debug)
-                               i_debug("acl: group added: %s", groups[i]);
+                       e_debug(user->event, "acl: group added: %s", groups[i]);
                }
                i_qsort(backend->groups, group_count, sizeof(const char *),
                        i_strcmp_p);
index 063e8b5ad796858adfcd7e6b73dd3503302f90d7..63cd1a0426d13aad6900e9693858de38c6439c32 100644 (file)
@@ -48,8 +48,8 @@ struct acl_lookup_dict *acl_lookup_dict_init(struct mail_user *user)
                dict_set.base_dir = user->set->base_dir;
                if (dict_init(uri, &dict_set, &dict->dict, &error) < 0)
                        i_error("acl: dict_init(%s) failed: %s", uri, error);
-       } else if (user->mail_debug) {
-               i_debug("acl: No acl_shared_dict setting - "
+       } else {
+               e_debug(user->event, "acl: No acl_shared_dict setting - "
                        "shared mailbox listing is disabled");
        }
        return dict;
index f9ec668f1bfc1510079db2f4cb1a026b8b45712b..bedf44b602cd2f27d924dd5da54f883d3781a31c 100644 (file)
@@ -220,10 +220,8 @@ acl_mailbox_list_iter_next_info(struct mailbox_list_iterate_context *_ctx)
                if (ctx->lookup_boxes == NULL ||
                    mailbox_tree_lookup(ctx->lookup_boxes, info->vname) != NULL)
                        break;
-               if (_ctx->list->ns->user->mail_debug) {
-                       i_debug("acl: Mailbox not in dovecot-acl-list: %s",
-                               info->vname);
-               }
+               e_debug(_ctx->list->ns->user->event,
+                       "acl: Mailbox not in dovecot-acl-list: %s", info->vname);
        }
 
        return info;
@@ -468,10 +466,8 @@ acl_mailbox_list_iter_next(struct mailbox_list_iterate_context *_ctx)
                        return NULL;
                }
                /* skip to next one */
-               if (_ctx->list->ns->user->mail_debug) {
-                       i_debug("acl: No lookup right to mailbox: %s",
-                               info->vname);
-               }
+               e_debug(_ctx->list->ns->user->event,
+                       "acl: No lookup right to mailbox: %s", info->vname);
        }
        return info == NULL ? NULL : &ctx->info;
 }
index a59c8891d717362b4d663ef9b0f88060e800e984..988c0b8b3e4d4626165fb60a8a27da81a5cd32be 100644 (file)
@@ -57,7 +57,6 @@ void acl_mail_user_created(struct mail_user *user)
        if (env != NULL && *env != '\0')
                acl_mail_user_create(user, env);
        else {
-               if (user->mail_debug)
-                       i_debug("acl: No acl setting - ACLs are disabled");
+               e_debug(user->event, "acl: No acl setting - ACLs are disabled");
        }
 }
index b3d87bcff1b6c08d672b8fc9714169ff2d448c0d..a847c5f1286a4b460e6655a8ccbcde043baefb78 100644 (file)
@@ -33,13 +33,11 @@ void apparmor_plugin_deinit(void);
 static void apparmor_log_current_context(struct mail_user *user)
 {
        char *con, *mode;
-       if (!user->mail_debug)
-               return;
 
        if (aa_getcon(&con, &mode) < 0) {
-               i_debug("aa_getcon() failed: %m");
+               e_debug(user->event, "aa_getcon() failed: %m");
        } else {
-               i_debug("apparmor: Current context=%s, mode=%s",
+               e_debug(user->event, "apparmor: Current context=%s, mode=%s",
                        con, mode);
                free(con);
        }
index b16ec0450a35830294c1f15d7ba7d689a8f5c3b5..b4fe3eca53872a38b058bd19e42f87b783fdcc75 100644 (file)
@@ -122,8 +122,7 @@ static unsigned int charset_aliases_init(struct mail_user *user, pool_t pool, co
                        continue;
                }
                if (strcasecmp(key, value) != 0) {
-                       if (user->mail_debug)
-                               i_debug("charset_alias: add charset-alias %s for %s", value, key);
+                       e_debug(user->event, "charset_alias: add charset-alias %s for %s", value, key);
                        alias.charset = p_strdup(pool, t_str_lcase(key));
                        alias.alias = p_strdup(pool, value);
                        array_append(&charset_aliases, &alias, 1);
index 1d109b1681e28fea29f76ed89f4a0be50fdd4147..13bc83f624e0289e0bb80bf0b5e07592258a4cae 100644 (file)
@@ -212,7 +212,6 @@ static int
 expire_mailbox_transaction_commit(struct mailbox_transaction_context *t,
                                  struct mail_transaction_commit_changes *changes_r)
 {
-       struct mail_user *user = t->box->storage->user;
        struct expire_mailbox *xpr_box = EXPIRE_CONTEXT_REQUIRE(t->box);
        struct expire_transaction_context *xt = EXPIRE_CONTEXT_REQUIRE(t);
        struct mailbox *box = t->box;
@@ -228,11 +227,8 @@ expire_mailbox_transaction_commit(struct mailbox_transaction_context *t,
                           transaction a new message was saved */
                        new_stamp = ioloop_time;
                }
-               if (user->mail_debug) {
-                       i_debug("expire: Expunging first message in %s, "
-                               "updating timestamp to %ld",
-                               box->vname, (long)new_stamp);
-               }
+               e_debug(box->event, "expire: Expunging first message, "
+                       "updating timestamp to %ld", (long)new_stamp);
                update_dict = TRUE;
        }
 
@@ -268,10 +264,9 @@ expire_mailbox_transaction_commit(struct mailbox_transaction_context *t,
                        } else {
                                /* already exists */
                        }
-                       if (user->mail_debug && update_dict) {
-                               i_debug("expire: Saving first message to %s, "
-                                       "updating timestamp to %ld",
-                                       box->vname, (long)new_stamp);
+                       if (update_dict) {
+                               e_debug(box->event, "expire: Saving first message, "
+                                       "updating timestamp to %ld", (long)new_stamp);
                        }
                }
 
@@ -412,8 +407,7 @@ static void expire_mail_user_created(struct mail_user *user)
        const char *dict_uri, *error;
 
        if (!mail_user_plugin_getenv_bool(user, "expire")) {
-               if (user->mail_debug)
-                       i_debug("expire: No expire setting - plugin disabled");
+               e_debug(user->event, "expire: No expire setting - plugin disabled");
                return;
        }
 
index ba38f8cbeec435af8974bd4b64aa20cce3a2bdd6..a4b8b5c3034f57e22e77caa759c090da6b62f8ba 100644 (file)
@@ -102,11 +102,9 @@ fts_tika_parser_response(const struct http_response *response,
        case 204: /* empty response */
        case 415: /* Unsupported Media Type */
        case 422: /* Unprocessable Entity */
-               if (parser->user->mail_debug) {
-                       i_debug("fts_tika: PUT %s failed: %s",
-                               mail_user_plugin_getenv(parser->user, "fts_tika"),
-                               http_response_get_message(response));
-               }
+               e_debug(parser->user->event, "fts_tika: PUT %s failed: %s",
+                       mail_user_plugin_getenv(parser->user, "fts_tika"),
+                       http_response_get_message(response));
                parser->payload = i_stream_create_from_data("", 0);
                break;
        default:
index c14fedc5da044fdf40251cfc745e134db7362c9c..a3fbb9eb64fb4284aa0902db3373f5d961afff51 100644 (file)
@@ -917,16 +917,15 @@ fts_mailbox_list_created(struct mailbox_list *list)
        const char *path;
 
        if (name == NULL || name[0] == '\0') {
-               if (list->mail_set->mail_debug)
-                       i_debug("fts: No fts setting - plugin disabled");
+               e_debug(list->ns->user->event,
+                       "fts: No fts setting - plugin disabled");
                return;
        }
 
        if (!mailbox_list_get_root_path(list, MAILBOX_LIST_PATH_TYPE_INDEX, &path)) {
-               if (list->mail_set->mail_debug) {
-                       i_debug("fts: Indexes disabled for namespace '%s'",
-                               list->ns->prefix);
-               }
+               e_debug(list->ns->user->event,
+                       "fts: Indexes disabled for namespace '%s'",
+                       list->ns->prefix);
                return;
        }
 
index 989e80a1f86717162b0bab8309f58592c7d91c35..ee5093d69d48ff7940863133ff961b641076c855 100644 (file)
@@ -596,8 +596,8 @@ static void lazy_expunge_mail_user_created(struct mail_user *user)
                        mail_user_plugin_getenv_bool(user, "lazy_expunge_only_last_instance");
 
                MODULE_CONTEXT_SET(user, lazy_expunge_mail_user_module, luser);
-       } else if (user->mail_debug) {
-               i_debug("lazy_expunge: No lazy_expunge setting - "
+       } else {
+               e_debug(user->event, "lazy_expunge: No lazy_expunge setting - "
                        "plugin disabled");
        }
 }
index dffd7064303ad34dd6a8f2f3cf7c2d2ad8f0653c..da80f34c2a9de0c006b155fd6ad289ca272a51b4 100644 (file)
@@ -405,10 +405,8 @@ static void mail_crypt_mail_user_created(struct mail_user *user)
        const char *curve = mail_user_plugin_getenv(user, "mail_crypt_curve");
        buffer_t *tmp = t_str_new(64);
        if (curve == NULL || *curve == '\0') {
-               if (user->mail_debug) {
-                       i_debug("mail_crypt_plugin: mail_crypt_curve setting "
-                               "missing - generating EC keys disabled");
-               }
+               e_debug(user->event, "mail_crypt_plugin: mail_crypt_curve setting "
+                       "missing - generating EC keys disabled");
        } else if (!dcrypt_name2oid(curve, tmp, &error)) {
                user->error = p_strdup_printf(user->pool,
                        "mail_crypt_plugin: "
index 3e3c8a7b15fd834144af01d59c2b1618a6b1aa8c..b152a7f01cf56fe595262284ec29e231c7f39b0e 100644 (file)
@@ -28,10 +28,9 @@ mail_crypt_load_global_private_keys(struct mail_user *user,
                                                        error_r) < 0) {
                        /* skip this key */
                        if (ignore_errors) {
-                               if (user->namespaces->mail_set->mail_debug)
-                                       i_debug("mail-crypt-plugin: "
-                                               "mail_crypt_load_global_private_key failed: %s",
-                                               *error_r);
+                               e_debug(user->event, "mail-crypt-plugin: "
+                                       "mail_crypt_load_global_private_key failed: %s",
+                                       *error_r);
                                *error_r = NULL;
                                continue;
                        }
index 4ecf4758b9a0c3268a332efadb48922b0c843fd2..923687ed97e7a05c90b6db9c6813a473fa4ae2d1 100644 (file)
@@ -167,10 +167,8 @@ mail_filter_parse_setting(struct mail_user *user, const char *name,
                *socket_path_r = p_strdup_printf(user->pool, "%s/%s",
                        user->set->base_dir, *socket_path_r);
        }
-       if (user->mail_debug) {
-               i_debug("mail_filter: Filtering %s via socket %s",
-                       name, *socket_path_r);
-       }
+       e_debug(user->event, "mail_filter: Filtering %s via socket %s",
+               name, *socket_path_r);
 }
 
 static void mail_filter_mail_user_created(struct mail_user *user)
@@ -186,9 +184,9 @@ static void mail_filter_mail_user_created(struct mail_user *user)
                                  &muser->socket_path, &muser->args);
        mail_filter_parse_setting(user, "mail_filter_out",
                                  &muser->out_socket_path, &muser->out_args);
-       if (user->mail_debug && muser->socket_path == NULL &&
+       if (muser->socket_path == NULL &&
            muser->out_socket_path == NULL) {
-               i_debug("mail_filter and mail_filter_out settings missing, "
+               e_debug(user->event, "mail_filter and mail_filter_out settings missing, "
                        "ignoring mail_filter plugin");
        }
 
index 04755f94bf9b749e4af817b5bca7db881e33a32c..b56428758c436ad432e25062493e34799b0d25a8 100644 (file)
@@ -130,9 +130,7 @@ static void notify_update_mailbox_status(struct mailbox *box)
        struct dict_transaction_context *t;
        struct mailbox_status status;
 
-       if (user->mail_debug)
-               i_debug("notify-status: Updating mailbox %s status",
-                       mailbox_get_vname(box));
+       e_debug(box->event, "notify-status: Updating mailbox status");
 
        box = mailbox_alloc(mailbox_get_namespace(box)->list,
                           mailbox_get_vname(box), MAILBOX_FLAG_READONLY);
@@ -194,9 +192,7 @@ static void notify_remove_mailbox_status(struct mailbox *box)
        i_assert(nuser != NULL);
        struct dict_transaction_context *t;
 
-       if (user->mail_debug)
-               i_debug("notify-status: Removing mailbox %s status",
-                       mailbox_get_vname(box));
+       e_debug(box->event, "notify-status: Removing mailbox status");
 
        const char *key =
                t_strdup_printf(NOTIFY_STATUS_KEY, mailbox_get_vname(box));
@@ -313,9 +309,8 @@ static void notify_status_mail_user_created(struct mail_user *user)
                return;
 
        if (uri == NULL || *uri == '\0') {
-               if (user->mail_debug)
-                       i_debug("notify-status: Disabled - Missing plugin/"
-                               NOTIFY_STATUS_SETTING_DICT_URI" setting");
+               e_debug(user->event, "notify-status: Disabled - Missing plugin/"
+                       NOTIFY_STATUS_SETTING_DICT_URI" setting");
                return;
        }
 
index 9932230f64e545008ab68ca78df0b41563358fc3..92c32c84f3d17d5693ed36bdb69d2166189c34b7 100644 (file)
@@ -690,10 +690,8 @@ static bool pop3_uidl_assign_by_size(struct mailbox *box)
                imap_map[i].pop3_seq = pop3_map[i].pop3_seq;
        }
        mbox->first_unfound_idx = i;
-       if (box->storage->user->mail_debug) {
-               i_debug("pop3_migration: cached uidls=%u, size matches=%u, total=%u",
-                       uidl_match, size_match, count);
-       }
+       e_debug(box->event, "pop3_migration: cached uidls=%u, size matches=%u, total=%u",
+               uidl_match, size_match, count);
        return i == count && imap_count == pop3_count;
 }
 
@@ -787,9 +785,8 @@ pop3_uidl_assign_by_hdr_hash(struct mailbox *box, struct mailbox *pop3_box)
                        return -1;
                }
                i_warning("%s", str_c(str));
-       } else if (box->storage->user->mail_debug) {
-               i_debug("pop3_migration: %u mails matched by headers", pop3_count);
-       }
+       } else
+               e_debug(box->event, "pop3_migration: %u mails matched by headers", pop3_count);
        array_sort(&mstorage->pop3_uidl_map, pop3_uidl_map_pop3_seq_cmp);
        array_sort(&mbox->imap_msg_map, imap_msg_map_uid_cmp);
        return 0;
@@ -1007,8 +1004,7 @@ static void pop3_migration_mail_storage_created(struct mail_storage *storage)
        pop3_box_vname = mail_user_plugin_getenv(storage->user,
                                                 "pop3_migration_mailbox");
        if (pop3_box_vname == NULL) {
-               if (storage->user->mail_debug)
-                       i_debug("pop3_migration: No pop3_migration_mailbox setting - disabled");
+               e_debug(storage->user->event, "pop3_migration: No pop3_migration_mailbox setting - disabled");
                return;
        }
 
index d58a48f314c99bdb18487dbb3727b228d13aa252..c36bf8410e723cfa417f7a004eb9ae41641258e7 100644 (file)
@@ -148,9 +148,9 @@ push_notification_driver_debug(const char *label, struct mail_user *user,
 {
     va_list args;
 
-    if (user->mail_debug) T_BEGIN {
+    T_BEGIN {
         va_start(args, fmt);
-        i_debug("%s%s", label, t_strdup_vprintf(fmt, args));
+        e_debug(user->event, "%s%s", label, t_strdup_vprintf(fmt, args));
         va_end(args);
     } T_END;
 }
index d01f1b052a0d04083c9f4b5148e139eb71f50564..489276acd98a9f44fb0e6d3acee93a1c0da78864 100644 (file)
@@ -269,9 +269,7 @@ static void quota_clone_mail_user_created(struct mail_user *user)
 
        uri = mail_user_plugin_getenv(user, "quota_clone_dict");
        if (uri == NULL || uri[0] == '\0') {
-               if (user->mail_debug) {
-                       i_debug("The quota_clone_dict setting is missing from configuration");
-               }
+               e_debug(user->event, "The quota_clone_dict setting is missing from configuration");
                return;
        }
 
index 74666f555c3d6b80dfc208fbccce659e84381b9b..7f335628a279c1e8a16732af8908e637b4ef8e15 100644 (file)
@@ -652,8 +652,8 @@ void quota_mail_user_created(struct mail_user *user)
                quser->quota = quota;
 
                MODULE_CONTEXT_SET(user, quota_user_module, quser);
-       } else if (user->mail_debug) {
-               i_debug("quota: No quota setting - plugin disabled");
+       } else {
+               e_debug(user->event, "quota: No quota setting - plugin disabled");
        }
 }
 
index 1fa883cf8d1d60fa834083e37035b5a8f0e82d0d..8d32b0c4a5e38e51b297deb39364ec40cf7546ab 100644 (file)
@@ -189,10 +189,9 @@ static void replication_notify(struct mail_namespace *ns,
        if (ruser == NULL)
                return;
 
-       if (ns->user->mail_debug) {
-               i_debug("replication: Replication requested by '%s', priority=%d",
-                       event, priority);
-       }
+       e_debug(ns->user->event,
+               "replication: Replication requested by '%s', priority=%d",
+               event, priority);
 
        if (priority == REPLICATION_PRIORITY_SYNC) {
                if (replication_notify_sync(ns->user) == 0) {
@@ -336,16 +335,14 @@ static void replication_user_created(struct mail_user *user)
 
        value = mail_user_plugin_getenv(user, "mail_replica");
        if (value == NULL || value[0] == '\0') {
-               if (user->mail_debug)
-                       i_debug("replication: No mail_replica setting - replication disabled");
+               e_debug(user->event, "replication: No mail_replica setting - replication disabled");
                return;
        }
 
        if (user->dsyncing) {
                /* we're running dsync, which means that the remote is telling
                   us about a change. don't trigger a replication back to it */
-               if (user->mail_debug)
-                       i_debug("replication: We're running dsync - replication disabled");
+               e_debug(user->event, "replication: We're running dsync - replication disabled");
                return;
        }
 
index 170924b8d9d5ab459645551087cc6b5b4aed8f2e..d03a16e6b11ef31b7168aedce41d73e9687d33d5 100644 (file)
@@ -176,19 +176,17 @@ err:
        }
 
        if (size_expunged < size_needed) {
-               if (ctx->quota->user->mail_debug) {
-                       i_debug("trash plugin: Failed to remove enough messages "
-                               "(needed %"PRIu64" bytes, expunged only %"PRIu64" bytes)",
-                               size_needed, size_expunged);
-               }
+               e_debug(ctx->quota->user->event,
+                       "trash plugin: Failed to remove enough messages "
+                       "(needed %"PRIu64" bytes, expunged only %"PRIu64" bytes)",
+                       size_needed, size_expunged);
                return 0;
        }
        if (expunged_count < count_needed) {
-               if (ctx->quota->user->mail_debug) {
-                       i_debug("trash plugin: Failed to remove enough messages "
-                               "(needed %u messages, expunged only %u messages)",
-                               count_needed, expunged_count);
-               }
+               e_debug(ctx->quota->user->event,
+                       "trash plugin: Failed to remove enough messages "
+                       "(needed %u messages, expunged only %u messages)",
+                       count_needed, expunged_count);
                return 0;
        }
 
@@ -327,10 +325,8 @@ static int read_configuration(struct mail_user *user, const char *path)
                        ret = -1;
                }
 
-               if (user->mail_debug) {
-                       i_debug("trash plugin: Added '%s' with priority %d",
-                               trash->name, trash->priority);
-               }
+               e_debug(user->event, "trash plugin: Added '%s' with priority %d",
+                       trash->name, trash->priority);
        }
        i_stream_destroy(&input);
        i_close_fd(&fd);
@@ -348,8 +344,7 @@ trash_mail_user_created(struct mail_user *user)
 
        env = mail_user_plugin_getenv(user, "trash");
        if (env == NULL) {
-               if (user->mail_debug)
-                       i_debug("trash: No trash setting - plugin disabled");
+               e_debug(user->event, "trash: No trash setting - plugin disabled");
        } else if (quser == NULL) {
                i_error("trash plugin: quota plugin not initialized");
        } else {
index a52d9b3bc2b85f6407ebf9e35c83ed6884ef23c7..9169dbfbf8ea554e67a68ca447f6ab2f80a1c02b 100644 (file)
@@ -208,11 +208,9 @@ static int virtual_backend_box_alloc(struct virtual_mailbox *mbox,
        }
        if (existence != MAILBOX_EXISTENCE_SELECT) {
                /* ignore this. it could be intentional. */
-               if (mbox->storage->storage.user->mail_debug) {
-                       i_debug("virtual mailbox %s: "
-                               "Skipping non-existing mailbox %s",
-                               mbox->box.vname, bbox->box->vname);
-               }
+               e_debug(mbox->box.event,
+                       "Skipping non-existing mailbox %s",
+                       bbox->box->vname);
                mailbox_free(&bbox->box);
                return 0;
        }
index 482a8b6d48e515c1c925f65aebefcdec419fe431..e98d1260454d71f8fb2e3946d00a4cb76b6f9083 100644 (file)
@@ -29,8 +29,7 @@ static void script_execute(struct mail_user *user, const char *cmd, bool wait)
        char buf[1024];
        int fd, ret;
 
-       if (user->mail_debug)
-               i_debug("welcome: Executing %s (wait=%d)", cmd, wait ? 1 : 0);
+       e_debug(user->event, "welcome: Executing %s (wait=%d)", cmd, wait ? 1 : 0);
 
        args = t_strsplit_spaces(cmd, " ");
        socket_path = args[0];