Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Apr 2018 16:26:46 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r332111 - head/usr.sbin/syslogd
Message-ID:  <201804061626.w36GQkh2033625@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Fri Apr  6 16:26:46 2018
New Revision: 332111
URL: https://svnweb.freebsd.org/changeset/base/332111

Log:
  Remove some places where error messages are prefixed with "syslogd".
  
  Due to using RFC 5424, the application name is stored in a dedicated
  field. It can simply be passed as an argument to logmsg() now.

Modified:
  head/usr.sbin/syslogd/syslogd.c

Modified: head/usr.sbin/syslogd/syslogd.c
==============================================================================
--- head/usr.sbin/syslogd/syslogd.c	Fri Apr  6 16:24:03 2018	(r332110)
+++ head/usr.sbin/syslogd/syslogd.c	Fri Apr  6 16:26:46 2018	(r332111)
@@ -1991,7 +1991,7 @@ domark(int signo __unused)
  * Print syslogd errors some place.
  */
 static void
-logerror(const char *type)
+logerror(const char *msg)
 {
 	char buf[512];
 	static int recursed = 0;
@@ -2000,15 +2000,15 @@ logerror(const char *type)
 	if (recursed)
 		return;
 	recursed++;
-	if (errno)
-		(void)snprintf(buf,
-		    sizeof buf, "syslogd: %s: %s", type, strerror(errno));
-	else
-		(void)snprintf(buf, sizeof buf, "syslogd: %s", type);
+	if (errno != 0) {
+		(void)snprintf(buf, sizeof(buf), "%s: %s", msg,
+		    strerror(errno));
+		msg = buf;
+	}
 	errno = 0;
 	dprintf("%s\n", buf);
-	logmsg(LOG_SYSLOG|LOG_ERR, NULL, LocalHostName, NULL, NULL, NULL,
-	    NULL, buf, 0);
+	logmsg(LOG_SYSLOG|LOG_ERR, NULL, LocalHostName, "syslogd", NULL, NULL,
+	    NULL, msg, 0);
 	recursed--;
 }
 
@@ -2355,18 +2355,18 @@ init(int signo)
 		}
 	}
 
-	logmsg(LOG_SYSLOG|LOG_INFO, NULL, LocalHostName, NULL, NULL, NULL,
-	    NULL, "syslogd: restart", 0);
+	logmsg(LOG_SYSLOG | LOG_INFO, NULL, LocalHostName, "syslogd", NULL,
+	    NULL, NULL, "restart", 0);
 	dprintf("syslogd: restarted\n");
 	/*
 	 * Log a change in hostname, but only on a restart.
 	 */
 	if (signo != 0 && strcmp(oldLocalHostName, LocalHostName) != 0) {
 		(void)snprintf(hostMsg, sizeof(hostMsg),
-		    "syslogd: hostname changed, \"%s\" to \"%s\"",
+		    "hostname changed, \"%s\" to \"%s\"",
 		    oldLocalHostName, LocalHostName);
-		logmsg(LOG_SYSLOG|LOG_INFO, NULL, LocalHostName, NULL, NULL,
-		    NULL, NULL, hostMsg, 0);
+		logmsg(LOG_SYSLOG | LOG_INFO, NULL, LocalHostName, "syslogd",
+		    NULL, NULL, NULL, hostMsg, 0);
 		dprintf("%s\n", hostMsg);
 	}
 	/*
@@ -2375,9 +2375,9 @@ init(int signo)
 	 */
 	if (signo == 0 && !use_bootfile) {
 		(void)snprintf(bootfileMsg, sizeof(bootfileMsg),
-		    "syslogd: kernel boot file is %s", bootfile);
-		logmsg(LOG_KERN|LOG_INFO, NULL, LocalHostName, NULL, NULL,
-		    NULL, NULL, bootfileMsg, 0);
+		    "kernel boot file is %s", bootfile);
+		logmsg(LOG_KERN | LOG_INFO, NULL, LocalHostName, "syslogd",
+		    NULL, NULL, NULL, bootfileMsg, 0);
 		dprintf("%s\n", bootfileMsg);
 	}
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201804061626.w36GQkh2033625>