[radvd-devel-l] default logging to stderr+syslog
Pekka Savola
pekkas at netcore.fi
Sun Jul 24 08:05:50 EDT 2005
Hi,
I've implemented a small change which changes the default logging
method to log everything to syslog (which was the default before), but
also high priority messages (at least LOG_ERR level) to stderr as
well.
Given that stderr logging (unless debugging is used) only works until
radvd forks, this is mostly useful for showing more clearly startup
errors, if any.
Comments?
--
Pekka Savola "You each name yourselves king, yet the
Netcore Oy kingdom bleeds."
Systems. Networks. Security. -- George R.R. Martin: A Clash of Kings
-------------- next part --------------
Index: CHANGES
===================================================================
RCS file: /work/cvsroot/radvd/CHANGES,v
retrieving revision 1.42
diff -u -r1.42 CHANGES
--- CHANGES 8 Jul 2005 11:50:32 -0000 1.42
+++ CHANGES 24 Jul 2005 11:53:43 -0000
@@ -1,5 +1,10 @@
$Id: CHANGES,v 1.42 2005/07/08 11:50:32 psavola Exp $
+07/24/2005 Implement a new logging method "stderr_syslog" which is
+ now also the default. Everything is logged on syslog,
+ while the most important messages (i.e., start-up failures)
+ are also logged on stderr.
+
07/08/2005 Release 0.8.
07/05/2005 Change the more-specific route ND option code
Index: log.c
===================================================================
RCS file: /work/cvsroot/radvd/log.c,v
retrieving revision 1.4
diff -u -r1.4 log.c
--- log.c 20 Jun 2004 17:52:41 -0000 1.4
+++ log.c 24 Jul 2005 11:53:43 -0000
@@ -34,6 +34,8 @@
case L_NONE:
case L_STDERR:
break;
+ case L_STDERR_SYSLOG:
+ /* fallthrough */
case L_SYSLOG:
if (facility == -1)
log_facility = LOG_DAEMON;
@@ -77,6 +79,11 @@
vsnprintf(buff, sizeof(buff), format, ap);
syslog(prio, "%s", buff);
break;
+ case L_STDERR_SYSLOG:
+ vsnprintf(buff, sizeof(buff), format, ap);
+ syslog(prio, "%s", buff);
+ if (prio > LOG_ERR) /* fall through for messages with high priority */
+ break;
case L_STDERR:
current = time(NULL);
tm = localtime(¤t);
Index: radvd.8.man
===================================================================
RCS file: /work/cvsroot/radvd/radvd.8.man,v
retrieving revision 1.9
diff -u -r1.9 radvd.8.man
--- radvd.8.man 23 Jul 2005 11:09:18 -0000 1.9
+++ radvd.8.man 24 Jul 2005 11:53:43 -0000
@@ -97,8 +97,12 @@
.B stderr
Logs to standard error.
.TP
+.B stderr_syslog
+Logs only the high messages (of at least LOG_ERR priority) to standard
+error, and everything to syslog (default method).
+.TP
.B syslog
-Logs to syslog (default method).
+Logs to syslog.
.RE
.PP
.TP
Index: radvd.c
===================================================================
RCS file: /work/cvsroot/radvd/radvd.c,v
retrieving revision 1.21
diff -u -r1.21 radvd.c
--- radvd.c 22 Mar 2005 10:29:13 -0000 1.21
+++ radvd.c 24 Jul 2005 11:53:43 -0000
@@ -82,7 +82,7 @@
srand((unsigned int)time(NULL));
- log_method = L_SYSLOG;
+ log_method = L_STDERR_SYSLOG;
logfile = PATH_RADVD_LOG;
conf_file = PATH_RADVD_CONF;
facility = LOG_FACILITY;
@@ -116,6 +116,10 @@
{
log_method = L_SYSLOG;
}
+ else if (!strcmp(optarg, "stderr_syslog"))
+ {
+ log_method = L_STDERR_SYSLOG;
+ }
else if (!strcmp(optarg, "stderr"))
{
log_method = L_STDERR;
Index: radvd.h
===================================================================
RCS file: /work/cvsroot/radvd/radvd.h,v
retrieving revision 1.12
diff -u -r1.12 radvd.h
--- radvd.h 15 Feb 2005 08:32:06 -0000 1.12
+++ radvd.h 24 Jul 2005 11:53:43 -0000
@@ -27,7 +27,8 @@
#define L_NONE 0
#define L_SYSLOG 1
#define L_STDERR 2
-#define L_LOGFILE 3
+#define L_STDERR_SYSLOG 3
+#define L_LOGFILE 4
#define LOG_TIME_FORMAT "%b %d %H:%M:%S"
More information about the radvd-devel-l
mailing list