SCCS-vsn: lib/libc/gen/syslog.c 4.4
-static char SccsId[] = "@(#)syslog.c 4.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)syslog.c 4.4 (Berkeley) %G%";
* adds a newline on the end of the message.
*
* The output of this routine is intended to be read by /etc/syslogd.
* adds a newline on the end of the message.
*
* The output of this routine is intended to be read by /etc/syslogd.
+ *
+ * Author: Eric Allman
+ * Modified to use UNIX domain IPC by Ralph Campbell
*/
#include <sys/types.h>
*/
#include <sys/types.h>
register char *b, *f, *o;
register int c;
long now;
register char *b, *f, *o;
register int c;
long now;
+ int pid, olderrno = errno;
/* see if we should just throw out this message */
/* see if we should just throw out this message */
+ if (pri < LOG_ALERT || pri > LogMask)
return;
if (LogFile < 0)
openlog(NULL, 0, 0);
o = outline;
return;
if (LogFile < 0)
openlog(NULL, 0, 0);
o = outline;
- if (pri > 0) {
- sprintf(o, "<%d>", pri);
- o += strlen(o);
- }
+ sprintf(o, "<%d>", pri);
+ o += strlen(o);
if (LogTag) {
strcpy(o, LogTag);
o += strlen(o);
}
if (LogStat & LOG_PID) {
if (LogTag) {
strcpy(o, LogTag);
o += strlen(o);
}
if (LogStat & LOG_PID) {
- sprintf(o, " (%d)", getpid());
+ sprintf(o, "[%d]", getpid());
o += strlen(o);
}
time(&now);
o += strlen(o);
}
time(&now);
- sprintf(o, " %.15s -- ", ctime(&now) + 4);
+ sprintf(o, ": %.15s-- ", ctime(&now) + 4);
- if ((unsigned)errno > sys_nerr)
- sprintf(b, "error %d", errno);
+ if ((unsigned)olderrno > sys_nerr)
+ sprintf(b, "error %d", olderrno);
- strcpy(b, sys_errlist[errno]);
+ strcpy(b, sys_errlist[olderrno]);
b += strlen(b);
}
*b++ = '\n';
b += strlen(b);
}
*b++ = '\n';
close(LogFile);
exit(0);
}
close(LogFile);
exit(0);
}
- while (wait((int *)0) != pid)
+ while ((c = wait((int *)0)) > 0 && c != pid)
+ LogTag = (ident != NULL) ? ident : "syslog";
LogStat = logstat;
if (logmask > 0 && logmask <= LOG_DEBUG)
LogMask = logmask;
LogStat = logstat;
if (logmask > 0 && logmask <= LOG_DEBUG)
LogMask = logmask;
int opri;
opri = LogMask;
int opri;
opri = LogMask;
+ if (pri > 0 && pri <= LOG_DEBUG)
+ LogMask = pri;