summaryrefslogtreecommitdiffstats
path: root/usr.sbin/syslogd/syslogd.c
diff options
context:
space:
mode:
authordd <dd@FreeBSD.org>2001-11-27 20:02:18 +0000
committerdd <dd@FreeBSD.org>2001-11-27 20:02:18 +0000
commitfc1c953f036a4566fcea0706db2bf97591882bd6 (patch)
tree23fe158df6d75855e87dd1653c716ce2a22c26d6 /usr.sbin/syslogd/syslogd.c
parentaeec5e42651c55da02aacf7c8dcf8fbf07a7a922 (diff)
downloadFreeBSD-src-fc1c953f036a4566fcea0706db2bf97591882bd6.zip
FreeBSD-src-fc1c953f036a4566fcea0706db2bf97591882bd6.tar.gz
Make the default kernel prefix "kernel:" instead of the boot file,
with the old behavior available via the -o option (it might still be useful if one has many kernels and cares which messages came from which). If the boot file is not used as the prefix, it is still logged once at startup. This change is prompted by the fact that the boot file is now much longer ("/boot/kernel/kernel" vs. "/kernel"), which significanlty bloats the syslogd output. Reviewed by: peter
Diffstat (limited to 'usr.sbin/syslogd/syslogd.c')
-rw-r--r--usr.sbin/syslogd/syslogd.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index b8d5202..0cfa84c 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -273,6 +273,7 @@ int family = PF_UNSPEC; /* protocol family (IPv4, IPv6 or both) */
int family = PF_INET; /* protocol family (IPv4 only) */
#endif
int send_to_all = 0; /* send message to all IPv4/IPv6 addresses */
+int use_bootfile = 0; /* log entire bootfile for every kern msg */
char bootfile[MAXLINE+1]; /* booted kernel file */
@@ -333,7 +334,7 @@ main(argc, argv)
socklen_t len;
bindhostname = NULL;
- while ((ch = getopt(argc, argv, "46Aa:b:df:kl:m:np:P:suv")) != -1)
+ while ((ch = getopt(argc, argv, "46Aa:b:df:kl:m:nop:P:suv")) != -1)
switch (ch) {
case '4':
family = PF_INET;
@@ -375,6 +376,9 @@ main(argc, argv)
case 'n':
resolve = 0;
break;
+ case 'o':
+ use_bootfile = 1;
+ break;
case 'p': /* path */
funixn[0] = optarg;
break;
@@ -807,7 +811,8 @@ logmsg(pri, msg, from, flags)
/* add kernel prefix for kernel messages */
if (flags & ISKERNEL) {
- snprintf(buf, sizeof(buf), "%s: %s", bootfile, msg);
+ snprintf(buf, sizeof(buf), "%s: %s",
+ use_bootfile ? bootfile : "kernel", msg);
msg = buf;
msglen = strlen(buf);
}
@@ -1337,6 +1342,7 @@ init(signo)
char host[MAXHOSTNAMELEN];
char oldLocalHostName[MAXHOSTNAMELEN];
char hostMsg[2*MAXHOSTNAMELEN+40];
+ char bootfileMsg[LINE_MAX];
dprintf("init\n");
@@ -1526,6 +1532,16 @@ init(signo)
logmsg(LOG_SYSLOG|LOG_INFO, hostMsg, LocalHostName, ADDDATE);
dprintf("%s\n", hostMsg);
}
+ /*
+ * Log the kernel boot file if we aren't going to use it as
+ * the prefix, and if this is *not* a restart.
+ */
+ if (signo == 0 && !use_bootfile) {
+ (void)snprintf(bootfileMsg, sizeof(bootfileMsg),
+ "syslogd: kernel boot file is %s", bootfile);
+ logmsg(LOG_KERN|LOG_INFO, bootfileMsg, LocalHostName, ADDDATE);
+ dprintf("%s\n", bootfileMsg);
+ }
}
/*
OpenPOWER on IntegriCloud