]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Replace "if(mail_debug){i_debug}" "e_debug"
authorSergey Kitov <sergey.kitov@open-xchange.com>
Tue, 20 Mar 2018 09:05:13 +0000 (11:05 +0200)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 7 Aug 2018 11:10:07 +0000 (14:10 +0300)
src/lib-storage/index/index-mail.c
src/lib-storage/index/index-status.c
src/lib-storage/index/index-storage.c
src/lib-storage/index/mbox/mbox-storage.c
src/lib-storage/index/shared/shared-storage.c
src/lib-storage/mail-namespace.c
src/lib-storage/mail-storage-service.c
src/lib-storage/mail-storage.c
src/lib-storage/mailbox-list.c

index 3b223d5cf7919c6c35de2ae38b067c3af1dd2c5b..f349377b05a0072d258abc38394d80d473b1c904 100644 (file)
@@ -1238,11 +1238,10 @@ int index_mail_init_stream(struct index_mail *mail,
        bool has_nuls, body_size_from_stream = FALSE;
        int ret;
 
-       if (_mail->box->storage->user->mail_debug &&
-           mail->mail.get_stream_reason != NULL &&
+       if (mail->mail.get_stream_reason != NULL &&
            mail->mail.get_stream_reason[0] != '\0') {
-               i_debug("Mailbox %s: Opened mail UID=%u because: %s",
-                       _mail->box->vname, _mail->uid,
+               e_debug(_mail->event,
+                       "Opened mail because: %s",
                        mail->mail.get_stream_reason);
        }
        _mail->mail_stream_opened = TRUE;
index 89edf5cb4d1e1ab5a7ace8a30f341f82f4256ec6..c7559e70429420076e3e10384402d64515617890 100644 (file)
@@ -260,8 +260,9 @@ static void get_metadata_precache_fields(struct mailbox *box,
                        cache |= MAIL_FETCH_GUID;
                else if (strcmp(name, "flags") == 0) {
                        /* just ignore for now at least.. */
-               } else if (box->storage->set->mail_debug)
-                       i_debug("Ignoring unknown cache field: %s", name);
+               } else
+                       e_debug(box->event,
+                               "Ignoring unknown cache field: %s", name);
        }
        metadata_r->precache_fields = cache;
 }
index 6c92832223f54e78a88e6298cbcebb74913e5dba..218b6241410f9b0b41c3ba569b79e7f2d2946d09 100644 (file)
@@ -395,7 +395,7 @@ void index_storage_mailbox_alloc(struct mailbox *box, const char *vname,
                mail_storage_settings_to_index_flags(box->storage->set);
        if ((box->flags & MAILBOX_FLAG_SAVEONLY) != 0)
                ibox->index_flags |= MAIL_INDEX_OPEN_FLAG_SAVEONLY;
-       if (box->storage->user->mail_debug)
+       if (event_want_debug(box->event))
                ibox->index_flags |= MAIL_INDEX_OPEN_FLAG_DEBUG;
        ibox->next_lock_notify = time(NULL) + LOCK_NOTIFY_INTERVAL;
        MODULE_CONTEXT_SET(box, index_storage_module, ibox);
index 8cd805841635e5ddc0d51d25c673ff333f03c2a7..71e7f2c6ffba06b905959537976e5b16d2715ae2 100644 (file)
@@ -185,8 +185,7 @@ static void mbox_storage_get_list_settings(const struct mail_namespace *ns,
 
        if (set->inbox_path == NULL) {
                set->inbox_path = t_strconcat(set->root_dir, "/inbox", NULL);
-               if (ns->mail_set->mail_debug)
-                       i_debug("mbox: INBOX defaulted to %s", set->inbox_path);
+               e_debug(ns->user->event, "mbox: INBOX defaulted to %s", set->inbox_path);
        }
 }
 
index b5092528aa969bfb5342163836976cfa09d0654f..a7168f5b4c0ea910ddc607765eecea56e93c24cd 100644 (file)
@@ -303,10 +303,9 @@ int shared_storage_get_namespace(struct mail_namespace **_ns,
        if (ret <= 0) {
                get_nonexistent_user_location(storage, userdomain, location);
                new_ns->flags |= NAMESPACE_FLAG_UNUSABLE;
-               if (ns->user->mail_debug) {
-                       i_debug("shared: Tried to access mails of "
-                               "nonexistent user %s", userdomain);
-               }
+               e_debug(ns->user->event,
+                       "shared: Tried to access mails of "
+                       "nonexistent user %s", userdomain);
        }
 
        ns_set = p_new(user->pool, struct mail_namespace_settings, 1);
index 1ea4ec78f142cdc001e4cdecf47751e10f6fabab..2c0340e45c10b848ed531ef38f6f32a2ce32e227 100644 (file)
@@ -155,17 +155,15 @@ int mail_namespaces_init_add(struct mail_user *user,
        if (*ns_set->location == '\0')
                ns_set->location = mail_set->mail_location;
 
-       if (mail_set->mail_debug) {
-               i_debug("Namespace %s: type=%s, prefix=%s, sep=%s, "
-                       "inbox=%s, hidden=%s, list=%s, subscriptions=%s "
-                       "location=%s",
-                       ns_set->name, ns_set->type, ns_set->prefix,
-                       ns_set->separator == NULL ? "" : ns_set->separator,
-                       ns_set->inbox ? "yes" : "no",
-                       ns_set->hidden ? "yes" : "no",
-                       ns_set->list,
-                       ns_set->subscriptions ? "yes" : "no", ns_set->location);
-       }
+       e_debug(user->event, "Namespace %s: type=%s, prefix=%s, sep=%s, "
+               "inbox=%s, hidden=%s, list=%s, subscriptions=%s "
+               "location=%s",
+               ns_set->name, ns_set->type, ns_set->prefix,
+               ns_set->separator == NULL ? "" : ns_set->separator,
+               ns_set->inbox ? "yes" : "no",
+               ns_set->hidden ? "yes" : "no",
+               ns_set->list,
+               ns_set->subscriptions ? "yes" : "no", ns_set->location);
 
        if ((ret = mail_namespace_alloc(user, user->set,
                                        ns_set, unexpanded_ns_set,
@@ -452,7 +450,6 @@ int mail_namespaces_init_finish(struct mail_namespace *namespaces,
 
 int mail_namespaces_init(struct mail_user *user, const char **error_r)
 {
-       const struct mail_storage_settings *mail_set;
        struct mail_namespace_settings *const *ns_set;
        struct mail_namespace_settings *const *unexpanded_ns_set;
        struct mail_namespace *namespaces, **ns_p;
@@ -462,7 +459,6 @@ int mail_namespaces_init(struct mail_user *user, const char **error_r)
 
         namespaces = NULL; ns_p = &namespaces;
 
-       mail_set = mail_user_set_get_storage_set(user);
        if (array_is_created(&user->set->namespaces)) {
                ns_set = array_get(&user->set->namespaces, &count);
                unexpanded_ns_set =
@@ -483,10 +479,8 @@ int mail_namespaces_init(struct mail_user *user, const char **error_r)
                                mail_namespaces_deinit(&namespaces);
                                return -1;
                        }
-                       if (mail_set->mail_debug) {
-                               i_debug("Skipping namespace %s: %s",
-                                       ns_set[i]->prefix, *error_r);
-                       }
+                       e_debug(user->event, "Skipping namespace %s: %s",
+                               ns_set[i]->prefix, *error_r);
                } else {
                        ns_p = &(*ns_p)->next;
                }
index afba1a91fcff87a10376dc1e08e9c1e6d2bf5917..d05351b8efc655eb5578ceb57e304a720a577265 100644 (file)
@@ -122,11 +122,9 @@ static void set_keyval(struct mail_storage_service_ctx *ctx,
 
        if (master_service_set_has_config_override(ctx->service, key)) {
                /* this setting was already overridden with -o parameter */
-               if (mail_user_set_get_mail_debug(user->user_info,
-                                                user->user_set)) {
-                       i_debug("Ignoring overridden (-o) userdb setting: %s",
-                               key);
-               }
+               e_debug(user->event,
+                       "Ignoring overridden (-o) userdb setting: %s",
+                       key);
                return;
        }
 
@@ -141,13 +139,10 @@ static int set_line(struct mail_storage_service_ctx *ctx,
                    const char *line)
 {
        struct setting_parser_context *set_parser = user->set_parser;
-       bool mail_debug;
        const char *key, *orig_key, *append_value = NULL;
        size_t len;
        int ret;
 
-       mail_debug = mail_user_set_get_mail_debug(user->user_info,
-                                                 user->user_set);
        if (strchr(line, '=') == NULL)
                line = t_strconcat(line, "=yes", NULL);
        orig_key = key = t_strcut(line, '=');
@@ -167,10 +162,8 @@ static int set_line(struct mail_storage_service_ctx *ctx,
 
        if (master_service_set_has_config_override(ctx->service, key)) {
                /* this setting was already overridden with -o parameter */
-               if (mail_debug) {
-                       i_debug("Ignoring overridden (-o) userdb setting: %s",
-                               key);
-               }
+               e_debug(user->event, "Ignoring overridden (-o) userdb setting: %s",
+                       key);
                return 1;
        }
 
@@ -191,13 +184,13 @@ static int set_line(struct mail_storage_service_ctx *ctx,
        }
 
        ret = settings_parse_line(set_parser, line);
-       if (mail_debug && ret >= 0) {
+       if (ret >= 0) {
                if (strstr(key, "pass") != NULL) {
                        /* possibly a password field (e.g. imapc_password).
                           hide the value. */
                        line = t_strconcat(key, "=<hidden>", NULL);
                }
-               i_debug(ret == 0 ?
+               e_debug(user->event, ret == 0 ?
                        "Unknown userdb setting: %s" :
                        "Added userdb setting: %s", line);
        }
@@ -661,7 +654,6 @@ mail_storage_service_init_post(struct mail_storage_service_ctx *ctx,
                               struct mail_user **mail_user_r,
                               const char **error_r)
 {
-       const struct mail_storage_settings *mail_set;
        const char *home = priv->home;
        struct mail_user_connection_data conn_data;
        struct mail_user *mail_user;
@@ -714,17 +706,13 @@ mail_storage_service_init_post(struct mail_storage_service_ctx *ctx,
        mail_user->userdb_fields = user->input.userdb_fields == NULL ? NULL :
                p_strarray_dup(mail_user->pool, user->input.userdb_fields);
        
-       mail_set = mail_user_set_get_storage_set(mail_user);
+       string_t *str = t_str_new(64);
 
-       if (mail_set->mail_debug) {
-               string_t *str = t_str_new(64);
-
-               str_printfa(str, "Effective uid=%s, gid=%s, home=%s",
-                           dec2str(geteuid()), dec2str(getegid()), home);
-               if (*priv->chroot != '\0')
-                       str_printfa(str, ", chroot=%s", priv->chroot);
-               i_debug("%s", str_c(str));
-       }
+       str_printfa(str, "Effective uid=%s, gid=%s, home=%s",
+                   dec2str(geteuid()), dec2str(getegid()), home);
+       if (*priv->chroot != '\0')
+               str_printfa(str, ", chroot=%s", priv->chroot);
+       e_debug(mail_user->event, "%s", str_c(str));
 
        if ((user->flags & MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP) != 0 &&
            (user->flags & MAIL_STORAGE_SERVICE_FLAG_ENABLE_CORE_DUMPS) == 0) {
@@ -751,8 +739,8 @@ mail_storage_service_init_post(struct mail_storage_service_ctx *ctx,
                                                t_strconcat(chdir_path, "/", NULL)));
                        } else if (errno != ENOENT)
                                i_error("chdir(%s) failed: %m", chdir_path);
-                       else if (mail_set->mail_debug)
-                               i_debug("Home dir not found: %s", chdir_path);
+                       else
+                               e_debug(mail_user->event, "Home dir not found: %s", chdir_path);
 
                        if (chdir("/") < 0)
                                i_error("chdir(/) failed: %m");
index c8d76e02a5ef3c5087e18ebf571a0b5ce38fe950..c651c887e7763a65ba6cdcb95bc39fa1994bfec6 100644 (file)
@@ -291,7 +291,8 @@ mail_storage_create_root(struct mailbox_list *list,
                /* we don't need to verify, but since debugging is
                   enabled, check and log if the root doesn't exist */
                if (mail_storage_verify_root(root_dir, type_name, &error) < 0) {
-                       i_debug("Namespace %s: Creating storage despite: %s",
+                       e_debug(list->ns->user->event,
+                               "Namespace %s: Creating storage despite: %s",
                                list->ns->prefix, error);
                }
                return 0;
@@ -1253,9 +1254,10 @@ mailbox_open_full(struct mailbox *box, struct istream *input)
        if (box->opened)
                return 0;
 
-       if (box->storage->set->mail_debug && box->reason != NULL) {
-               i_debug("%s: Mailbox opened because: %s",
-                       box->vname, box->reason);
+       if (box->reason != NULL) {
+               e_debug(box->event,
+                       "Mailbox opened because: %s",
+                       box->reason);
        }
 
        switch (box->open_error) {
@@ -1811,10 +1813,9 @@ int mailbox_rename(struct mailbox *src, struct mailbox *dest)
                                             dest->storage, &error) ||
            !mailbox_lists_rename_compatible(src->list,
                                             dest->list, &error)) {
-               if (src->storage->set->mail_debug) {
-                       i_debug("Can't rename '%s' to '%s': %s",
-                               src->vname, dest->vname, error);
-               }
+               e_debug(src->event,
+                       "Can't rename '%s' to '%s': %s",
+                       src->vname, dest->vname, error);
                mail_storage_set_error(src->storage, MAIL_ERROR_NOTPOSSIBLE,
                        "Can't rename mailboxes across specified storages.");
                return -1;
index 43c4ac2bfe78e67e3ef9cc8d1edce76660282bc5..f482dab14e9c80cd952a518b71bdecad3c526acd 100644 (file)
@@ -209,18 +209,17 @@ int mailbox_list_create(const char *driver, struct mail_namespace *ns,
                }
        }
 
-       if (ns->mail_set->mail_debug) {
-               i_debug("%s: root=%s, index=%s, indexpvt=%s, control=%s, inbox=%s, alt=%s",
-                       list->name,
-                       list->set.root_dir == NULL ? "" : list->set.root_dir,
-                       list->set.index_dir == NULL ? "" : list->set.index_dir,
-                       list->set.index_pvt_dir == NULL ? "" : list->set.index_pvt_dir,
-                       list->set.control_dir == NULL ?
-                       "" : list->set.control_dir,
-                       list->set.inbox_path == NULL ?
-                       "" : list->set.inbox_path,
-                       list->set.alt_dir == NULL ? "" : list->set.alt_dir);
-       }
+       e_debug(ns->user->event,
+               "%s: root=%s, index=%s, indexpvt=%s, control=%s, inbox=%s, alt=%s",
+               list->name,
+               list->set.root_dir == NULL ? "" : list->set.root_dir,
+               list->set.index_dir == NULL ? "" : list->set.index_dir,
+               list->set.index_pvt_dir == NULL ? "" : list->set.index_pvt_dir,
+               list->set.control_dir == NULL ?
+               "" : list->set.control_dir,
+               list->set.inbox_path == NULL ?
+               "" : list->set.inbox_path,
+               list->set.alt_dir == NULL ? "" : list->set.alt_dir);
        if ((flags & MAILBOX_LIST_FLAG_SECONDARY) == 0)
                mail_namespace_finish_list_init(ns, list);
 
@@ -937,8 +936,9 @@ mailbox_list_get_permissions_stat(struct mailbox_list *list, const char *path,
                } else if (!ENOTFOUND(errno)) {
                        mailbox_list_set_critical(list, "stat(%s) failed: %m",
                                                  path);
-               } else if (list->mail_set->mail_debug) {
-                       i_debug("Namespace %s: %s doesn't exist yet, "
+               } else {
+                       e_debug(list->ns->user->event,
+                               "Namespace %s: %s doesn't exist yet, "
                                "using default permissions",
                                list->ns->prefix, path);
                }
@@ -1055,8 +1055,9 @@ mailbox_list_get_permissions_internal(struct mailbox_list *list,
                                         list->pool);
        }
 
-       if (list->mail_set->mail_debug && name == NULL) {
-               i_debug("Namespace %s: Using permissions from %s: "
+       if (name == NULL) {
+               e_debug(list->ns->user->event,
+                       "Namespace %s: Using permissions from %s: "
                        "mode=0%o gid=%s", list->ns->prefix,
                        path != NULL ? path : "",
                        (int)permissions_r->dir_create_mode,