[OpenAFS-devel] add syslog support to bosserver
Nathan Neulinger
nneul@umr.edu
Thu, 15 Mar 2001 08:36:52 -0600
--82I3+IH0IqGh5yIs
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Simple patch to add "-syslog" option to bosserver. Causes it to direct all
logging activity to syslogd instead of to logs/BosLog.
I'll be doing a bunch of these, figured I'd send them for each server
process one at a time.
Right now, it's ifdef'd out for NT... might be worthwhile to have -syslog
send to EventLog on NT systems. If one were to do there, where would be
the appropriate place (library) to place a 'syslog' routine for NT? Seems
like that'd be the cleanest approach - just implement a syslog routine
that has equivalent calling conventions, and then use syslog() regardless
of OS.
-- Nathan
------------------------------------------------------------
Nathan Neulinger EMail: nneul@umr.edu
University of Missouri - Rolla Phone: (573) 341-4841
Computing Services Fax: (573) 341-4216
--82I3+IH0IqGh5yIs
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="bos-syslog.diff"
Index: bozo/bosserver.c
===================================================================
RCS file: /cvs/openafs/src/bozo/bosserver.c,v
retrieving revision 1.6
diff -u -r1.6 bosserver.c
--- bozo/bosserver.c 2001/03/05 19:13:24 1.6
+++ bozo/bosserver.c 2001/03/15 14:32:08
@@ -24,6 +24,7 @@
#else
#include <unistd.h>
#include <netinet/in.h>
+#include <syslog.h>
#endif /* AFS_NT40_ENV */
#include <afs/cellconfig.h>
#include <rx/rx.h>
@@ -55,6 +56,7 @@
extern int rx_stackSize; /* for rx_SetStackSize macro */
int DoLogging = 0;
+int DoSyslog = 0;
static afs_int32 nextRestart;
static afs_int32 nextDay;
@@ -116,6 +118,13 @@
argv[i] = "-log";
i++;
}
+#ifndef AFS_NT40_ENV
+ /* if syslog logging is on, pass "-syslog" to new bosserver */
+ if (DoSyslog) {
+ argv[i] = "-syslog";
+ i++;
+ }
+#endif
/* null-terminate argument list */
argv[i] = NULL;
@@ -714,6 +723,12 @@
/* set extra logging flag */
DoLogging = 1;
}
+#ifndef AFS_NT40_ENV
+ else if (strcmp(argv[code], "-syslog")==0) {
+ /* set syslog logging flag */
+ DoSyslog = 1;
+ }
+#endif
else if (strcmp(argv[code], "-enable_peer_stats")==0) {
rx_enablePeerRPCStats();
}
@@ -730,6 +745,9 @@
/* hack to support help flag */
printf("Usage: bosserver [-noauth] [-log] "
+#ifndef AFS_NT40_ENV
+ "[-syslog] "
+#endif
/* "[-enable_peer_stats] [-enable_process_stats] " */
"[-help]\n");
fflush(stdout);
@@ -773,19 +791,27 @@
#endif /* ! AFS_NT40_ENV */
/* switch to logging information to the BosLog file */
- strcpy(namebuf, AFSDIR_BOZLOG_FILE);
- strcat(namebuf, ".old");
- renamefile(AFSDIR_BOZLOG_FILE, namebuf); /* try rename first */
- bozo_logFile = fopen(AFSDIR_BOZLOG_FILE, "a");
- if (!bozo_logFile) {
- printf("bosserver: can't initialize log file (%s).\n",
- AFSDIR_SERVER_BOZLOG_FILEPATH);
- exit(1);
- }
-
- /* keep log closed normally, so can be removed */
+ if ( ! DoSyslog )
+ {
+ strcpy(namebuf, AFSDIR_BOZLOG_FILE);
+ strcat(namebuf, ".old");
+ renamefile(AFSDIR_BOZLOG_FILE, namebuf); /* try rename first */
+ bozo_logFile = fopen(AFSDIR_BOZLOG_FILE, "a");
+ if (!bozo_logFile) {
+ printf("bosserver: can't initialize log file (%s).\n",
+ AFSDIR_SERVER_BOZLOG_FILEPATH);
+ exit(1);
+ }
- fclose(bozo_logFile);
+ /* keep log closed normally, so can be removed */
+ fclose(bozo_logFile);
+ }
+ else
+ {
+#ifndef AFS_NT40_ENV
+ openlog("bosserver", LOG_PID, LOG_DAEMON);
+#endif
+ }
/* Write current state of directory permissions to log file */
DirAccessOK ();
@@ -881,6 +907,15 @@
char tdate[26];
time_t myTime;
+ if ( DoSyslog )
+ {
+#ifndef AFS_NT40_ENV
+ syslog(LOG_INFO, a, b, c, d, e, f);
+#endif
+ }
+ else
+ {
+
myTime = time(0);
strcpy(tdate, ctime(&myTime)); /* copy out of static area asap */
tdate[24] = ':';
@@ -907,4 +942,6 @@
/* close so rm BosLog works */
fclose(bozo_logFile);
+
+ }
}
--82I3+IH0IqGh5yIs--