summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>2016-11-04 14:26:35 +0100
committerHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>2016-11-04 14:26:35 +0100
commit2333e06f406b5d66068cef3e20ab223fc6650307 (patch)
treef0f133a8dfc8c2177fbbbdb43580d4f5089e8244 /src
parent0df394b5d5e6865094f601baf2a71f41d1d3ad95 (diff)
Add syslog_pid option.
This option suppresses the PID duplication to syslog. As syslog/systemd add the PID of the logging process automatically.
Diffstat (limited to 'src')
-rw-r--r--src/src/globals.c1
-rw-r--r--src/src/globals.h1
-rw-r--r--src/src/log.c8
-rw-r--r--src/src/readconf.c1
4 files changed, 10 insertions, 1 deletions
diff --git a/src/src/globals.c b/src/src/globals.c
index dcdd6f880..b862015a2 100644
--- a/src/src/globals.c
+++ b/src/src/globals.c
@@ -1384,6 +1384,7 @@ BOOL suppress_local_fixups_default = FALSE;
BOOL synchronous_delivery = FALSE;
BOOL syslog_duplication = TRUE;
int syslog_facility = LOG_MAIL;
+BOOL syslog_pid = TRUE;
uschar *syslog_processname = US"exim";
BOOL syslog_timestamp = TRUE;
uschar *system_filter = NULL;
diff --git a/src/src/globals.h b/src/src/globals.h
index 3e91c427d..b3747a84a 100644
--- a/src/src/globals.h
+++ b/src/src/globals.h
@@ -890,6 +890,7 @@ extern BOOL suppress_local_fixups_default; /* former is reset to this; overri
extern BOOL synchronous_delivery; /* TRUE if -odi is set */
extern BOOL syslog_duplication; /* FALSE => no duplicate logging */
extern int syslog_facility; /* As defined by Syslog.h */
+extern BOOL syslog_pid; /* TRUE if PID on syslogs */
extern uschar *syslog_processname; /* 'ident' param to openlog() */
extern BOOL syslog_timestamp; /* TRUE if time on syslogs */
extern uschar *system_filter; /* Name of system filter file */
diff --git a/src/src/log.c b/src/src/log.c
index 6eb57ca75..081e47bf9 100644
--- a/src/src/log.c
+++ b/src/src/log.c
@@ -47,6 +47,8 @@ static BOOL path_inspected = FALSE;
static int logging_mode = LOG_MODE_FILE;
static uschar *file_path = US"";
+static size_t pid_position[2];
+
/* These should be kept in-step with the private delivery error
number definitions in macros.h */
@@ -132,7 +134,7 @@ can get here if there is a failure to open the panic log.)
Arguments:
priority syslog priority
- s the string to be written
+ s the string to be written, the string may be modified!
Returns: nothing
*/
@@ -146,6 +148,8 @@ int linecount = 0;
if (running_in_test_harness) return;
if (!syslog_timestamp) s += log_timezone? 26 : 20;
+if (!syslog_pid && LOGGING(pid))
+ memmove(s + pid_position[0], s + pid_position[1], pid_position[1] - pid_position[0]);
len = Ustrlen(s);
@@ -905,7 +909,9 @@ while(*ptr) ptr++;
if (LOGGING(pid))
{
sprintf(CS ptr, "[%d] ", (int)getpid());
+ if (!syslog_pid) pid_position[0] = ptr - log_buffer; // remember begin …
while (*ptr) ptr++;
+ if (!syslog_pid) pid_position[1] = ptr - log_buffer; // … and end+1 of the PID
}
if (really_exim && message_id[0] != 0)
diff --git a/src/src/readconf.c b/src/src/readconf.c
index 9cbad8474..27a834b3f 100644
--- a/src/src/readconf.c
+++ b/src/src/readconf.c
@@ -445,6 +445,7 @@ static optionlist optionlist_config[] = {
{ "strip_trailing_dot", opt_bool, &strip_trailing_dot },
{ "syslog_duplication", opt_bool, &syslog_duplication },
{ "syslog_facility", opt_stringptr, &syslog_facility_str },
+ { "syslog_pid", opt_bool, &syslog_pid },
{ "syslog_processname", opt_stringptr, &syslog_processname },
{ "syslog_timestamp", opt_bool, &syslog_timestamp },
{ "system_filter", opt_stringptr, &system_filter },