]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lmtp: Improved logging.
authorTimo Sirainen <tss@iki.fi>
Thu, 5 Nov 2009 22:55:36 +0000 (17:55 -0500)
committerTimo Sirainen <tss@iki.fi>
Thu, 5 Nov 2009 22:55:36 +0000 (17:55 -0500)
--HG--
branch : HEAD

src/lmtp/client.c
src/lmtp/commands.c
src/lmtp/main.c

index 4f46b20187cbf8891dd1b1f14c741c66ef2d0d2b..536af4c25d7788571473a6702ffc66b4032c58a9 100644 (file)
@@ -178,6 +178,16 @@ static void client_generate_session_id(struct client *client)
        client->state.session_id = p_strdup(client->state_pool, str_c(id));
 }
 
+static const char *client_remote_id(struct client *client)
+{
+       const char *addr;
+
+       addr = net_ip2addr(&client->remote_ip);
+       if (addr == NULL)
+               addr = "local";
+       return addr;
+}
+
 struct client *client_create(int fd_in, int fd_out,
                             const struct master_service_connection *conn)
 {
@@ -216,6 +226,7 @@ struct client *client_create(int fd_in, int fd_out,
 
        client_send_line(client, "220 %s Dovecot LMTP ready",
                         client->my_domain);
+       i_info("Connect from %s", client_remote_id(client));
        return client;
 }
 
@@ -269,7 +280,7 @@ void client_disconnect(struct client *client, const char *prefix,
                client_send_line(client, "%s %s", prefix, reason);
        else
                reason = client_get_disconnect_reason(client);
-       i_info("%s", reason);
+       i_info("Disconnect from %s: %s", client_remote_id(client), reason);
 
        client->disconnected = TRUE;
 }
index 9464e704261c92517bd9a0eddb91a4d7e4616d59..649d7d824782fa0314a926ef4faabe087646a58b 100644 (file)
@@ -5,6 +5,7 @@
 #include "array.h"
 #include "str.h"
 #include "strescape.h"
+#include "hostpid.h"
 #include "istream.h"
 #include "istream-concat.h"
 #include "ostream.h"
@@ -402,7 +403,8 @@ client_deliver(struct client *client, const struct mail_recipient *rcpt,
        enum mail_error mail_error;
        int ret;
 
-       i_set_failure_prefix(t_strdup_printf("lmtp(%s): ", rcpt->name));
+       i_set_failure_prefix(t_strdup_printf("lmtp(%s, %s): ",
+                                            my_pid, rcpt->name));
        if (mail_storage_service_next(storage_service, rcpt->service_user,
                                      &client->state.dest_user,
                                      &error) < 0) {
@@ -465,7 +467,7 @@ static bool client_deliver_next(struct client *client, struct mail *src_mail)
        while (client->state.rcpt_idx < count) {
                ret = client_deliver(client, &rcpts[client->state.rcpt_idx],
                                     src_mail);
-               i_set_failure_prefix("lmtp: ");
+               i_set_failure_prefix(t_strdup_printf("lmtp(%s): ", my_pid));
 
                client->state.rcpt_idx++;
                if (ret == 0)
index ff41f5ff6446abc711b13c4e41b6e607858c939a..946dec2ab5493e012634aceb816ca686ca231d67 100644 (file)
@@ -3,6 +3,7 @@
 #include "lib.h"
 #include "array.h"
 #include "ioloop.h"
+#include "hostpid.h"
 #include "restrict-access.h"
 #include "fd-close-on-exec.h"
 #include "master-service.h"
@@ -55,7 +56,8 @@ int main(int argc, char *argv[])
        enum mail_storage_service_flags storage_service_flags =
                MAIL_STORAGE_SERVICE_FLAG_DISALLOW_ROOT |
                MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP |
-               MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP;
+               MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP |
+               MAIL_STORAGE_SERVICE_NO_LOG_INIT;
 
        if (IS_STANDALONE()) {
                service_flags |= MASTER_SERVICE_FLAG_STANDALONE |
@@ -67,6 +69,8 @@ int main(int argc, char *argv[])
        if (master_getopt(master_service) > 0)
                return FATAL_DEFAULT;
        master_service_init_finish(master_service);
+       master_service_init_log(master_service,
+                               t_strdup_printf("lmtp(%s): ", my_pid));
 
        storage_service = mail_storage_service_init(master_service, set_roots,
                                                    storage_service_flags);