]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
log: Include PID in prefix for internal log messages.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 24 Aug 2017 14:00:30 +0000 (17:00 +0300)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Fri, 25 Aug 2017 12:21:11 +0000 (15:21 +0300)
src/log/log-connection.c
src/log/log-connection.h
src/log/main.c

index 5080d1324a1680f8445624fd8b5996c0a8e5be58..b300a87ee9d79867d333b1ac0c4aa38b72c944aa 100644 (file)
@@ -145,7 +145,7 @@ client_log_ctx(struct log_connection *log,
        }
        i_set_failure_prefix("%s", prefix);
        i_log_type(ctx, "%s", text);
-       i_set_failure_prefix("log: ");
+       i_set_failure_prefix("%s", global_log_prefix);
 }
 
 static void
index 8d2a368a0b2f2388f127720978a2f4205743e27b..291942f4fc14cda018bfc297fe9b40a14c97e117 100644 (file)
@@ -4,6 +4,7 @@
 struct log_connection;
 
 extern bool verbose_proctitle;
+extern const char *global_log_prefix;
 
 void log_connection_create(struct log_error_buffer *errorbuf,
                           int fd, int listen_fd);
index e547683f6ca5c307a5d2ff5ac8205d7c6734e8fb..e58a9c20a84a08e656f5330d03e70b171424b2c6 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "lib.h"
 #include "lib-signals.h"
+#include "hostpid.h"
 #include "restrict-access.h"
 #include "master-interface.h"
 #include "master-service.h"
 #include <unistd.h>
 
 bool verbose_proctitle;
+const char *global_log_prefix;
 static struct log_error_buffer *errorbuf;
 
 static void
 sig_reopen_logs(const siginfo_t *si ATTR_UNUSED, void *context ATTR_UNUSED)
 {
-       master_service_init_log(master_service, "log: ");
+       master_service_init_log(master_service, global_log_prefix);
 }
 
 static void main_init(void)
@@ -62,7 +64,8 @@ int main(int argc, char *argv[])
 
        /* use log prefix and log to stderr until we've configured the real
           logging */
-       i_set_failure_file("/dev/stderr", "log: ");
+       global_log_prefix = t_strdup_printf("log(%s): ", my_pid);
+       i_set_failure_file("/dev/stderr", global_log_prefix);
 
        if (master_getopt(master_service) > 0)
                return FATAL_DEFAULT;
@@ -70,7 +73,7 @@ int main(int argc, char *argv[])
        if (master_service_settings_read_simple(master_service,
                                                NULL, &error) < 0)
                i_fatal("Error reading configuration: %s", error);
-       master_service_init_log(master_service, "log: ");
+       master_service_init_log(master_service, global_log_prefix);
 
        verbose_proctitle = master_service_settings_get(master_service)->verbose_proctitle;