From: Sergey Kitov Date: Tue, 20 Mar 2018 09:20:44 +0000 (+0200) Subject: plugins: replace "if(mail_debug){i_debug}" with "e_debug" X-Git-Tag: 2.3.3.rc1~171 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f4922ff56a2d64d1dd7e7892bdeae7cddeaea383;p=thirdparty%2Fdovecot%2Fcore.git plugins: replace "if(mail_debug){i_debug}" with "e_debug" --- diff --git a/src/plugins/acl/acl-backend.c b/src/plugins/acl/acl-backend.c index 026aef59c5..0514dc736f 100644 --- a/src/plugins/acl/acl-backend.c +++ b/src/plugins/acl/acl-backend.c @@ -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); diff --git a/src/plugins/acl/acl-lookup-dict.c b/src/plugins/acl/acl-lookup-dict.c index 063e8b5ad7..63cd1a0426 100644 --- a/src/plugins/acl/acl-lookup-dict.c +++ b/src/plugins/acl/acl-lookup-dict.c @@ -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; diff --git a/src/plugins/acl/acl-mailbox-list.c b/src/plugins/acl/acl-mailbox-list.c index f9ec668f1b..bedf44b602 100644 --- a/src/plugins/acl/acl-mailbox-list.c +++ b/src/plugins/acl/acl-mailbox-list.c @@ -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; } diff --git a/src/plugins/acl/acl-storage.c b/src/plugins/acl/acl-storage.c index a59c8891d7..988c0b8b3e 100644 --- a/src/plugins/acl/acl-storage.c +++ b/src/plugins/acl/acl-storage.c @@ -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"); } } diff --git a/src/plugins/apparmor/apparmor-plugin.c b/src/plugins/apparmor/apparmor-plugin.c index b3d87bcff1..a847c5f128 100644 --- a/src/plugins/apparmor/apparmor-plugin.c +++ b/src/plugins/apparmor/apparmor-plugin.c @@ -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); } diff --git a/src/plugins/charset-alias/charset-alias-plugin.c b/src/plugins/charset-alias/charset-alias-plugin.c index b16ec0450a..b4fe3eca53 100644 --- a/src/plugins/charset-alias/charset-alias-plugin.c +++ b/src/plugins/charset-alias/charset-alias-plugin.c @@ -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); diff --git a/src/plugins/expire/expire-plugin.c b/src/plugins/expire/expire-plugin.c index 1d109b1681..13bc83f624 100644 --- a/src/plugins/expire/expire-plugin.c +++ b/src/plugins/expire/expire-plugin.c @@ -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; } diff --git a/src/plugins/fts/fts-parser-tika.c b/src/plugins/fts/fts-parser-tika.c index ba38f8cbee..a4b8b5c303 100644 --- a/src/plugins/fts/fts-parser-tika.c +++ b/src/plugins/fts/fts-parser-tika.c @@ -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: diff --git a/src/plugins/fts/fts-storage.c b/src/plugins/fts/fts-storage.c index c14fedc5da..a3fbb9eb64 100644 --- a/src/plugins/fts/fts-storage.c +++ b/src/plugins/fts/fts-storage.c @@ -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; } diff --git a/src/plugins/lazy-expunge/lazy-expunge-plugin.c b/src/plugins/lazy-expunge/lazy-expunge-plugin.c index 989e80a1f8..ee5093d69d 100644 --- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c +++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c @@ -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"); } } diff --git a/src/plugins/mail-crypt/mail-crypt-plugin.c b/src/plugins/mail-crypt/mail-crypt-plugin.c index dffd706430..da80f34c2a 100644 --- a/src/plugins/mail-crypt/mail-crypt-plugin.c +++ b/src/plugins/mail-crypt/mail-crypt-plugin.c @@ -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: " diff --git a/src/plugins/mail-crypt/mail-crypt-userenv.c b/src/plugins/mail-crypt/mail-crypt-userenv.c index 3e3c8a7b15..b152a7f01c 100644 --- a/src/plugins/mail-crypt/mail-crypt-userenv.c +++ b/src/plugins/mail-crypt/mail-crypt-userenv.c @@ -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; } diff --git a/src/plugins/mail-filter/mail-filter-plugin.c b/src/plugins/mail-filter/mail-filter-plugin.c index 4ecf4758b9..923687ed97 100644 --- a/src/plugins/mail-filter/mail-filter-plugin.c +++ b/src/plugins/mail-filter/mail-filter-plugin.c @@ -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"); } diff --git a/src/plugins/notify-status/notify-status-plugin.c b/src/plugins/notify-status/notify-status-plugin.c index 04755f94bf..b56428758c 100644 --- a/src/plugins/notify-status/notify-status-plugin.c +++ b/src/plugins/notify-status/notify-status-plugin.c @@ -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; } diff --git a/src/plugins/pop3-migration/pop3-migration-plugin.c b/src/plugins/pop3-migration/pop3-migration-plugin.c index 9932230f64..92c32c84f3 100644 --- a/src/plugins/pop3-migration/pop3-migration-plugin.c +++ b/src/plugins/pop3-migration/pop3-migration-plugin.c @@ -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; } diff --git a/src/plugins/push-notification/push-notification-drivers.c b/src/plugins/push-notification/push-notification-drivers.c index d58a48f314..c36bf8410e 100644 --- a/src/plugins/push-notification/push-notification-drivers.c +++ b/src/plugins/push-notification/push-notification-drivers.c @@ -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; } diff --git a/src/plugins/quota-clone/quota-clone-plugin.c b/src/plugins/quota-clone/quota-clone-plugin.c index d01f1b052a..489276acd9 100644 --- a/src/plugins/quota-clone/quota-clone-plugin.c +++ b/src/plugins/quota-clone/quota-clone-plugin.c @@ -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; } diff --git a/src/plugins/quota/quota-storage.c b/src/plugins/quota/quota-storage.c index 74666f555c..7f335628a2 100644 --- a/src/plugins/quota/quota-storage.c +++ b/src/plugins/quota/quota-storage.c @@ -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"); } } diff --git a/src/plugins/replication/replication-plugin.c b/src/plugins/replication/replication-plugin.c index 1fa883cf8d..8d32b0c4a5 100644 --- a/src/plugins/replication/replication-plugin.c +++ b/src/plugins/replication/replication-plugin.c @@ -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; } diff --git a/src/plugins/trash/trash-plugin.c b/src/plugins/trash/trash-plugin.c index 170924b8d9..d03a16e6b1 100644 --- a/src/plugins/trash/trash-plugin.c +++ b/src/plugins/trash/trash-plugin.c @@ -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 { diff --git a/src/plugins/virtual/virtual-storage.c b/src/plugins/virtual/virtual-storage.c index a52d9b3bc2..9169dbfbf8 100644 --- a/src/plugins/virtual/virtual-storage.c +++ b/src/plugins/virtual/virtual-storage.c @@ -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; } diff --git a/src/plugins/welcome/welcome-plugin.c b/src/plugins/welcome/welcome-plugin.c index 482a8b6d48..e98d126045 100644 --- a/src/plugins/welcome/welcome-plugin.c +++ b/src/plugins/welcome/welcome-plugin.c @@ -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];