diff --git a/src/syslog.c b/src/syslog.c index 206ebec..4b8b0f1 100644 --- a/src/syslog.c +++ b/src/syslog.c @@ -477,11 +477,21 @@ output: DEC(); cnt = p - tbuf; - /* Output to stderr if requested. */ + /* Output to stderr if requested, PTRIM logs only message. */ if (data->log_stat & LOG_PERROR) { + struct iovec *piov; + int piovcnt; + iov[iovcnt].iov_base = __UNCONST(CRLF + 1); iov[iovcnt].iov_len = 1; - (void)writev(STDERR_FILENO, iov, iovcnt + 1); + if (data->log_stat & LOG_PTRIM) { + piov = &iov[iovcnt - 1]; + piovcnt = 2; + } else { + piov = iov; + piovcnt = iovcnt + 1; + } + (void)writev(STDERR_FILENO, piov, piovcnt + 1); } /* Don't write to system log, instead use fd in log_file */ diff --git a/src/syslog.h b/src/syslog.h index 49df25d..e1c6f47 100644 --- a/src/syslog.h +++ b/src/syslog.h @@ -187,7 +187,7 @@ CODE facilitynames[] = { #define LOG_NDELAY 0x008 /* don't delay open */ #define LOG_NOWAIT 0x010 /* don't wait for console forks: DEPRECATED */ #define LOG_PERROR 0x020 /* log to stderr as well */ -#define LOG_PTRIM 0x040 /* trim tag and pid from messages to stderr */ +#define LOG_PTRIM 0x040 /* trim anything syslog addded when writing to stderr */ #define LOG_NLOG 0x080 /* don't write to the system log */ #define LOG_STDOUT 0x100 /* like nlog, for debugging syslogp() API */ #define LOG_RFC3164 0x200 /* Log to remote/ipc socket in old BSD format */