diff options
author | julian <julian@FreeBSD.org> | 1998-06-10 04:34:56 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 1998-06-10 04:34:56 +0000 |
commit | 538c54fd9e27ac35ca3365167e7978a19cce6a14 (patch) | |
tree | e05188214d574c48c1c094849bcf92e73bc2b805 | |
parent | aa1c40519a99461008e57eb85b0d52a508042021 (diff) | |
download | FreeBSD-src-538c54fd9e27ac35ca3365167e7978a19cce6a14.zip FreeBSD-src-538c54fd9e27ac35ca3365167e7978a19cce6a14.tar.gz |
Allow syslogd to separate out kernel log messages with a known
category.
e.g. separate out ipfw entries to a separate file.
Reviewed by: (briefly) phk
Submitted by: archie@whistle.com
Obtained from: Whistle source tree
-rw-r--r-- | usr.sbin/syslogd/syslog.conf.5 | 9 | ||||
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 19 |
2 files changed, 22 insertions, 6 deletions
diff --git a/usr.sbin/syslogd/syslog.conf.5 b/usr.sbin/syslogd/syslog.conf.5 index f8e214d..f650e06 100644 --- a/usr.sbin/syslogd/syslog.conf.5 +++ b/usr.sbin/syslogd/syslog.conf.5 @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)syslog.conf.5 8.1 (Berkeley) 6/9/93 -.\" $Id: syslog.conf.5,v 1.8 1997/10/06 20:37:50 joerg Exp $ +.\" $Id: syslog.conf.5,v 1.9 1997/10/20 12:55:47 charnier Exp $ .\" .Dd June 9, 1993 .Dt SYSLOG.CONF 5 @@ -114,7 +114,8 @@ or (the former is for compatibility with the previous syslogd, if one is sharing syslog.conf files, for example) and each block will be associated with calls to syslog from that specific -program. +program. A tag for ``foo'' will also match any message logged by the kernel +with the prefix ``foo: ''. .Pp See .Xr syslog 3 @@ -294,6 +295,10 @@ auth.* |exec /usr/local/sbin/authfilter # Save ftpd transactions along with mail and news !ftpd *.* /var/log/spoolerr + +# Log kernel firewall reports to a separate file +!ipfw +*.* /var/log/ipfw .Ed .Sh FILES .Bl -tag -width /etc/syslog.conf -compact diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 3cd6353..7497648 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)syslogd.c 8.3 (Berkeley) 4/4/94"; #endif static const char rcsid[] = - "$Id: syslogd.c,v 1.31 1998/05/07 00:39:56 brian Exp $"; + "$Id: syslogd.c,v 1.32 1998/05/19 12:02:41 phk Exp $"; #endif /* not lint */ /* @@ -543,10 +543,9 @@ printsys(msg) int c, pri, flags; char *lp, *p, *q, line[MAXLINE + 1]; - (void)strcpy(line, bootfile); - (void)strcat(line, ": "); - lp = line + strlen(line); for (p = msg; *p != '\0'; ) { + + /* Get message priority, if any */ flags = SYNC_FILE | ADDDATE; /* fsync file after write */ pri = DEFSPRI; if (*p == '<') { @@ -561,6 +560,18 @@ printsys(msg) } if (pri &~ (LOG_FACMASK|LOG_PRIMASK)) pri = DEFSPRI; + + /* See if kernel provided a prefix; if not, use kernel name */ + for (q = p; *q && isalnum(*q); q++); + if (*q == ':') { + lp = line; + } else { + (void)strcpy(line, bootfile); + (void)strcat(line, ": "); + lp = line + strlen(line); + } + + /* Append message body to prefix */ q = lp; while (*p != '\0' && (c = *p++) != '\n' && q < &line[MAXLINE]) |