Adjust log file output format in BSD mode to output proc[PID] too

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg 2022-07-31 17:17:25 +02:00
parent 0811315f35
commit 5662afe2c0

View File

@ -295,17 +295,20 @@ vsyslogp_r(int pri, struct syslog_data *data, const char *msgid,
if (data->log_tag == NULL) if (data->log_tag == NULL)
data->log_tag = getprogname(); data->log_tag = getprogname();
prlen = snprintf(p, tbuf_left, "%s", data->log_tag); if (data->log_pid == -1)
DEC(); data->log_pid = getpid();
if (data->log_stat & LOG_PID) { if (data->log_stat & LOG_PID)
if (data->log_pid == -1) prlen = snprintf(p, tbuf_left, "%s[%d]: ", data->log_tag,
data->log_pid = getpid(); data->log_pid);
prlen = snprintf(p, tbuf_left, "[%d]", data->log_pid); else
DEC(); prlen = snprintf(p, tbuf_left, "%s: ", data->log_tag);
if (data->log_stat & (LOG_PERROR|LOG_CONS|LOG_NLOG)) {
iov[iovcnt].iov_base = p;
iov[iovcnt].iov_len = prlen;
iovcnt++;
} }
strlcat(p, ":", tbuf_left);
prlen = 1;
DEC(); DEC();
goto output; goto output;
} }