AC_CHECK_FUNCS([ \
arc4random \
+ closelog \
fcntl \
fseeko64 \
ftello64 \
getrlimit \
issetugid \
mkstemp \
+ openlog \
poll \
pread \
preadv \
strerror \
sysconf \
sysctl \
+ syslog \
tdestroy \
timegm \
])
afs_int32 numClasses;
extern int rx_stackSize;
+ struct logOptions logopts;
#ifdef AFS_NT40_ENV
/* initialize winsock */
memset(&cellinfo_s, 0, sizeof(cellinfo_s));
memset(clones, 0, sizeof(clones));
+ memset(&logopts, 0, sizeof(logopts));
+ logopts.lopt_dest = logDest_file;
+ logopts.lopt_filename = AFSDIR_SERVER_BUDBLOG_FILEPATH;
+ logopts.lopt_rotateOnOpen = 1;
+ logopts.lopt_rotateStyle = logRotate_old;
+
osi_audit_init();
osi_audit(BUDB_StartEvent, 0, AUD_END);
BUDB_EXIT(0);
/* open the log file */
- OpenLog(AFSDIR_SERVER_BUDBLOG_FILEPATH);
+ OpenLog(&logopts);
/* open the cell's configuration directory */
LogDebug(4, "opening %s\n", globalConfPtr->cellConfigdir);
void
kalog_Init(void)
{
- OpenLog(AFSDIR_SERVER_KALOGDB_FILEPATH); /* set up logging */
+ struct logOptions logopts;
+
+ memset(&logopts, 0, sizeof(logopts));
+ logopts.lopt_dest = logDest_file;
+ logopts.lopt_filename = AFSDIR_SERVER_KALOGDB_FILEPATH;
+ logopts.lopt_rotateOnOpen = 1;
+ logopts.lopt_rotateStyle = logRotate_old;
+ OpenLog(&logopts);
SetupLogSignals();
kalog_db =
dbm_open(AFSDIR_SERVER_KALOG_FILEPATH, O_WRONLY | O_CREAT,
char clones[MAXHOSTSPERCELL];
afs_uint32 host = ntohl(INADDR_ANY);
char *auditFileName = NULL;
+ struct logOptions logopts;
struct rx_service *tservice;
struct rx_securityClass *sca[1];
#endif
osi_audit_init();
+ memset(&logopts, 0, sizeof(logopts));
+
if (argc == 0) {
usage:
printf("Usage: kaserver [-noAuth] [-database <dbpath>] "
* text logging. So open the AuthLog file for logging and redirect
* stdin and stdout to it
*/
- OpenLog(AFSDIR_SERVER_KALOG_FILEPATH);
+ logopts.lopt_dest = logDest_file;
+ logopts.lopt_filename = AFSDIR_SERVER_KALOG_FILEPATH;
+ logopts.lopt_rotateOnOpen = 1;
+ logopts.lopt_rotateStyle = logRotate_old;
+
+ OpenLog(&logopts);
SetupLogSignals();
#endif
OPT_debug,
OPT_logfile,
OPT_threads,
+#ifdef HAVE_SYSLOG
OPT_syslog,
+#endif
OPT_peer,
OPT_process,
OPT_rxbind,
char *pr_dbaseName;
char *configDir;
- char *logFile;
+ struct logOptions logopts;
char *whoami = "ptserver";
char *auditFileName = NULL;
pr_dbaseName = strdup(AFSDIR_SERVER_PRDB_FILEPATH);
configDir = strdup(AFSDIR_SERVER_ETC_DIRPATH);
- logFile = strdup(AFSDIR_SERVER_PTLOG_FILEPATH);
+ memset(&logopts, 0, sizeof(logopts));
#if defined(SUPERGROUPS)
/* make sure the structures for database records are the same size */
CMD_OPTIONAL, "location of logfile");
cmd_AddParmAtOffset(opts, OPT_threads, "-p", CMD_SINGLE,
CMD_OPTIONAL, "number of threads");
-#if !defined(AFS_NT40_ENV)
+#ifdef HAVE_SYSLOG
cmd_AddParmAtOffset(opts, OPT_syslog, "-syslog", CMD_SINGLE_OR_FLAG,
CMD_OPTIONAL, "log to syslog");
#endif
free(interface);
}
- cmd_OptionAsInt(opts, OPT_debug, &LogLevel);
cmd_OptionAsString(opts, OPT_database, &pr_dbaseName);
- cmd_OptionAsString(opts, OPT_logfile, &logFile);
if (cmd_OptionAsInt(opts, OPT_threads, &lwps) == 0) {
if (lwps > 64) { /* maximum of 64 */
}
}
-#ifndef AFS_NT40_ENV
+#ifdef HAVE_SYSLOG
if (cmd_OptionPresent(opts, OPT_syslog)) {
- serverLogSyslog = 1;
- cmd_OptionAsInt(opts, OPT_syslog, &serverLogSyslogFacility);
- }
+ if (cmd_OptionPresent(opts, OPT_logfile)) {
+ fprintf(stderr, "Invalid options: -syslog and -logfile are exclusive.");
+ PT_EXIT(1);
+ }
+ logopts.lopt_dest = logDest_syslog;
+ logopts.lopt_facility = LOG_DAEMON;
+ logopts.lopt_tag = "ptserver";
+ cmd_OptionAsInt(opts, OPT_syslog, &logopts.lopt_facility);
+ } else
#endif
+ {
+ logopts.lopt_dest = logDest_file;
+ logopts.lopt_rotateOnOpen = 1;
+ logopts.lopt_rotateStyle = logRotate_old;
+
+ if (cmd_OptionPresent(opts, OPT_logfile))
+ cmd_OptionAsString(opts, OPT_logfile, (char**)&logopts.lopt_filename);
+ else
+ logopts.lopt_filename = AFSDIR_SERVER_PTLOG_FILEPATH;
+ }
+ cmd_OptionAsInt(opts, OPT_debug, &logopts.lopt_logLevel);
/* rx options */
if (cmd_OptionPresent(opts, OPT_peer))
osi_audit(PTS_StartEvent, 0, AUD_END);
}
-#ifndef AFS_NT40_ENV
- serverLogSyslogTag = "ptserver";
-#endif
- OpenLog(logFile); /* set up logging */
+ OpenLog(&logopts);
#ifdef AFS_PTHREAD_ENV
opr_softsig_Init();
SetupLogSoftSignals();
#include <stdarg.h>
#include <string.h>
-extern int LogLevel;
-extern int mrafsStyleLogs;
-#ifndef AFS_NT40_ENV
-extern int serverLogSyslog;
-extern int serverLogSyslogFacility;
-extern char *serverLogSyslogTag;
+enum logDest {
+ logDest_file,
+#ifdef HAVE_SYSLOG
+ logDest_syslog,
+#endif
+};
+
+enum logRotateStyle {
+ logRotate_none = 0,
+ logRotate_old, /**< Rename log file by adding .old to the file name. */
+ logRotate_timestamp, /**< Rename log file to a timestamped file name. */
+};
+
+struct logOptions {
+ int logLevel; /**< The initial log level. */
+ enum logDest dest; /**< Log destination */
+ union {
+ struct fileOptions {
+ const char *filename; /**< Log filename (may be a named pipe). */
+ int rotateOnOpen; /**< Rotate the log file during OpenLog. */
+ int rotateOnReset; /**< Rotate the log file when the SIGHUP is caught. */
+ enum logRotateStyle rotateStyle; /**< Specifies how logs are renamed. */
+ } fileOpts;
+#ifdef HAVE_SYSLOG
+ struct syslogOptions {
+ int facility; /**< The syslog facility. */
+ char *tag; /**< The syslog identification. */
+ } syslogOpts;
#endif
+ } opts;
+};
+#define lopt_logLevel logLevel
+#define lopt_dest dest
+#define lopt_filename opts.fileOpts.filename
+#define lopt_rotateOnOpen opts.fileOpts.rotateOnOpen
+#define lopt_rotateOnReset opts.fileOpts.rotateOnReset
+#define lopt_rotateStyle opts.fileOpts.rotateStyle
+#define lopt_facility opts.syslogOpts.facility
+#define lopt_tag opts.syslogOpts.tag
+
extern void vFSLog(const char *format, va_list args)
AFS_ATTRIBUTE_FORMAT(__printf__, 1, 0);
extern void FSLog(const char *format, ...)
AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2);
+
+extern int LogLevel; /* For logging macros only. */
+
#define ViceLog(level, str) do { if ((level) <= LogLevel) (FSLog str); } while (0)
#define vViceLog(level, str) do { if ((level) <= LogLevel) (vFSLog str); } while (0)
#define ViceLogThenPanic(level, str) \
do { ViceLog(level, str); osi_Panic str; } while(0);
-extern int OpenLog(const char *filename);
+extern int OpenLog(struct logOptions *opts);
extern int ReOpenLog(void);
extern void SetupLogSignals(void);
extern void CloseLog(void);
extern void SetupLogSoftSignals(void);
+extern int GetLogLevel(void);
+extern enum logDest GetLogDest(void);
+extern const char *GetLogFilename(void);
#ifdef AFS_NT40_ENV
#ifndef _MFC_VER
/* serverLog.c */
+struct logOptions;
extern void WriteLogBuffer(char *buf, afs_uint32 len);
extern void SetDebug_Signal(int signo);
extern void ResetDebug_Signal(int signo);
extern void SetupLogSignals(void);
-extern int OpenLog(const char *fileName);
+extern int OpenLog(struct logOptions *opts);
extern int ReOpenLog(void);
extern int LogThreadNum(void);
extern void LogCommandLine(int argc, char **argv, const char *progname,
const char *version, const char *logstring,
void (*log) (const char *format, ...));
extern void LogDesWarning(void);
+extern int GetLogLevel(void);
+extern enum logDest GetLogDest(void);
+extern const char *GetLogFilename(void);
/* snprintf.c */
initAFSDirPath
int64_to_flipbase64
ktime_DateToInt32
-mrafsStyleLogs
pthread_recursive_mutex_lock
pthread_recursive_mutex_lock
pthread_recursive_mutex_unlock
pthread_recursive_mutex_unlock
-serverLogSyslog
-serverLogSyslogFacility
-serverLogSyslogTag
util_GetHumanInt32
util_GetInt32
util_GetInt64
/* After single-threaded startup, accesses to serverlogFD and
* serverLogSyslog* are protected by LOCK_SERVERLOG(). */
static int serverLogFD = -1;
-
-#ifndef AFS_NT40_ENV
-int serverLogSyslog = 0;
-int serverLogSyslogFacility = LOG_DAEMON;
-char *serverLogSyslogTag = 0;
-#endif
+static struct logOptions serverLogOpts;
int LogLevel;
-int mrafsStyleLogs = 0;
static int threadIdLogs = 0;
static int resetSignals = 0;
static char *ourName = NULL;
+static int OpenLogFile(const char *fileName);
static void RotateLogFile(void);
/*!
return (lstat(fileName, &statbuf) == 0) && (S_ISFIFO(statbuf.st_mode));
}
+/*!
+ * Return the current logging level.
+ */
+int
+GetLogLevel(void)
+{
+ return LogLevel;
+}
+
+/*!
+ * Return the log destination.
+ */
+enum logDest
+GetLogDest(void)
+{
+ return serverLogOpts.lopt_dest;
+}
+
+/*!
+ * Get the log filename for file based logging.
+ *
+ * An empty string is returned if the log destination is not
+ * file based. The caller must make a copy of the string
+ * if it is accessed after the CloseLog.
+ */
+const char *
+GetLogFilename(void)
+{
+ return serverLogOpts.lopt_dest == logDest_file ? (const char*)ourName : "";
+}
+
void
SetLogThreadNumProgram(int (*func) (void) )
{
len = strlen(tbuffer);
LOCK_SERVERLOG();
-#ifndef AFS_NT40_ENV
- if (serverLogSyslog) {
+#ifdef HAVE_SYSLOG
+ if (serverLogOpts.dest == logDest_syslog) {
syslog(LOG_INFO, "%s", info);
} else
#endif
UNLOCK_SERVERLOG();
#if !defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
- if (!serverLogSyslog) {
+ if (serverLogOpts.dest == logDest_file) {
fflush(stdout);
fflush(stderr); /* in case they're sharing the same FD */
}
{
int code;
char *nextName = NULL;
-
- if (mrafsStyleLogs) {
- int tries;
- time_t t;
- struct stat buf;
- struct tm *timeFields;
-
+ int tries;
+ time_t t;
+ struct stat buf;
+ struct tm *timeFields;
+
+ switch (serverLogOpts.lopt_rotateStyle) {
+ case logRotate_none:
+ break;
+ case logRotate_old:
+ code = asprintf(&nextName, "%s.old", fileName);
+ if (code < 0) {
+ nextName = NULL;
+ }
+ break;
+ case logRotate_timestamp:
time(&t);
for (tries = 0; nextName == NULL && tries < 100; t++, tries++) {
timeFields = localtime(&t);
nextName = NULL;
}
}
- } else {
- code = asprintf(&nextName, "%s.old", fileName);
- if (code < 0) {
- nextName = NULL;
- }
+ break;
+ default:
+ opr_Assert(0);
}
if (nextName != NULL) {
rk_rename(fileName, nextName); /* Don't check the error code. */
if (threadIdLogs == 1)
threadIdLogs = 0;
#endif
- if (mrafsStyleLogs) {
+ if (serverLogOpts.lopt_rotateOnReset) {
RotateLogFile();
}
} /*ResetDebug_Signal */
}
}
-int
-OpenLog(const char *fileName)
+/*!
+ * Open the log file.
+ *
+ * Open the log file using the options given in OpenLog().
+ *
+ * \returns 0 on success
+ */
+static int
+OpenLogFile(const char *fileName)
{
/*
* This function should allow various libraries that inconsistently
* use stdout/stderr to all go to the same place
*/
int tempfd;
- int flags = O_WRONLY | O_TRUNC | O_CREAT | O_APPEND;
+ int flags = O_WRONLY | O_CREAT | O_APPEND;
-#if defined(AFS_PTHREAD_ENV)
- opr_Verify(pthread_once(&serverLogOnce, InitServerLogMutex) == 0);
-#endif /* AFS_PTHREAD_ENV */
-
-#ifndef AFS_NT40_ENV
- if (serverLogSyslog) {
- openlog(serverLogSyslogTag, LOG_PID, serverLogSyslogFacility);
- return (0);
- }
-#endif
+ opr_Assert(serverLogOpts.dest == logDest_file);
opr_Assert(fileName != NULL);
if (IsFIFO(fileName)) {
/* Support named pipes as logs by not rotating them. */
flags |= O_NONBLOCK;
- } else {
+ } else if (serverLogOpts.lopt_rotateOnOpen) {
+ /* Old style logging always started a new log file. */
+ flags |= O_TRUNC;
RenameLogFile(fileName);
}
serverLogFD = tempfd;
return 0;
+}
+
+/*!
+ * Open the log file descriptor or a connection to the system log.
+ *
+ * This function should be called once during program initialization and
+ * must be called before calling FSLog() or WriteLogBuffer(). The
+ * fields of the given argument specify the logging destination and
+ * various optional features.
+ *
+ * The lopt_logLevel value specifies the initial logging level.
+ *
+ * The lopt_dest enum specifies the logging destination; either
+ * file based (logDest_file) or the system log (logDest_syslog).
+ *
+ * File Based Logging
+ * ------------------
+ *
+ * A file will be opened for log messages when the lopt_dest enum is set
+ * to logDest_file. The file specified by lopt_filename will be opened
+ * for appending log messages. A new file will be created if the log
+ * file does not exist.
+ *
+ * The lopt_rotateOnOpen flag specifies whether an existing log file is
+ * to be renamed and a new log file created during the call to OpenLog.
+ * The lopt_rotateOnOpen flag has no effect if the file given by
+ * lopt_filename is a named pipe (fifo).
+ *
+ * The lopt_rotateOnReset flag specifies whether the log file is renamed
+ * and then reopened when the reset signal (SIGHUP) is caught.
+ *
+ * The lopt_rotateStyle enum specifies how the new log file is renamed when
+ * lopt_rotateOnOpen or lopt_rotateOnReset are set. The lopt_rotateStyle
+ * may be the traditional Transarc style (logRotate_old) or the MR-AFS
+ * style (logRotate_timestamp).
+ *
+ * When lopt_rotateStyle is set to logRotate_old, the suffix ".old" is
+ * appended to the log file name. The existing ".old" log file is
+ * removed.
+ *
+ * When lopt_rotateStyle is set to logRotate_timestamp, a timestamp
+ * string is appended to the log file name and existing files are not
+ * removed.
+ *
+ * \note Messages written to stdout and stderr are redirected to the log
+ * file when file-based logging is in effect.
+ *
+ * System Logging
+ * --------------
+ *
+ * A connection to the system log (syslog) will be established for log
+ * messages when the lopt_dest enum is set to logDest_syslog.
+ *
+ * The lopt_facility specifies the system log facility to be used when
+ * writing messages to the system log.
+ *
+ * The lopt_tag string specifies the indentification string to be used
+ * when writing messages to the system log.
+ *
+ * \param opts logging options. A copy of the logging
+ * options will be made before returning to
+ * the caller.
+ *
+ * \returns 0 on success
+ */
+int
+OpenLog(struct logOptions *opts)
+{
+ int code;
+
+#if defined(AFS_PTHREAD_ENV)
+ opr_Verify(pthread_once(&serverLogOnce, InitServerLogMutex) == 0);
+#endif /* AFS_PTHREAD_ENV */
+
+ LogLevel = serverLogOpts.logLevel = opts->logLevel;
+ serverLogOpts.dest = opts->dest;
+ switch (serverLogOpts.dest) {
+ case logDest_file:
+ serverLogOpts.lopt_rotateOnOpen = opts->lopt_rotateOnOpen;
+ serverLogOpts.lopt_rotateOnReset = opts->lopt_rotateOnReset;
+ serverLogOpts.lopt_rotateStyle = opts->lopt_rotateStyle;
+ /* OpenLogFile() sets ourName; don't cache filename here. */
+ code = OpenLogFile(opts->lopt_filename);
+ break;
+#ifdef HAVE_SYSLOG
+ case logDest_syslog:
+ serverLogOpts.lopt_rotateOnOpen = 0;
+ serverLogOpts.lopt_rotateOnReset = 0;
+ serverLogOpts.lopt_rotateStyle = logRotate_none;
+ openlog(opts->lopt_tag, LOG_PID, opts->lopt_facility);
+ code = 0;
+ break;
+#endif
+ default:
+ opr_Assert(0);
+ }
+ return code;
} /*OpenLog */
/*!
{
int flags = O_WRONLY | O_APPEND | O_CREAT;
-#if !defined(AFS_NT40_ENV)
- if (serverLogSyslog) {
+#ifdef HAVE_SYSLOG
+ if (serverLogOpts.dest == logDest_syslog) {
return 0;
}
#endif
close(serverLogFD);
serverLogFD = -1;
}
- OpenLog(ourName);
+ OpenLogFile(ourName);
}
UNLOCK_SERVERLOG();
}
CloseLog(void)
{
LOCK_SERVERLOG();
-#ifndef AFS_NT40_ENV
- if (serverLogSyslog) {
+
+#ifdef HAVE_SYSLOG
+ if (serverLogOpts.dest == logDest_syslog) {
closelog();
} else
#endif
struct afs_FSStats afs_fsstats;
-int LogLevel = 0;
int supported = 1;
int Console = 0;
afs_int32 BlocksSpare = 1024; /* allow 1 MB overruns */
extern int SystemId;
extern int AnonymousID;
extern prlist AnonCPS;
-extern int LogLevel;
extern struct afsconf_dir *confDir; /* config dir object */
extern int lwps; /* the max number of server threads */
extern afsUUID FS_HostUUID;
if (chain->hostPtr->z.interface &&
afs_uuid_equal(&chain->hostPtr->z.interface->uuid, uuid)) {
- if (LogLevel >= 125) {
+ if (GetLogLevel() >= 125) {
afsUUID_to_string(&chain->hostPtr->z.interface->uuid, uuid1,
127);
afsUUID_to_string(uuid, uuid2, 127);
chain->hostPtr = host;
chain->next = hostUuidHashTable[index];
hostUuidHashTable[index] = chain;
- if (LogLevel < 125)
+ if (GetLogLevel() < 125)
return;
afsUUID_to_string(uuid, uuid2, 127);
ViceLog(125,
/* hash into proper bucket */
index = h_UuidHashIndex(&host->z.interface->uuid);
- if (LogLevel >= 125)
+ if (GetLogLevel() >= 125)
afsUUID_to_string(&host->z.interface->uuid, uuid1, 127);
for (uhp = &hostUuidHashTable[index]; (uth = *uhp); uhp = &uth->next) {
opr_Assert(uth->hostPtr);
h_AddHostToUuidHashTable_r(&interface->uuid, host);
- if (LogLevel >= 125) {
+ if (GetLogLevel() >= 125) {
afsUUID_to_string(&interface->uuid, uuidstr, 127);
ViceLog(125, ("--- uuid %s\n", uuidstr));
#include <afs/audit.h>
#include <afs/partition.h>
#include <afs/dir.h>
+#include <afs/afsutil.h>
#include "viced_prototypes.h"
#include "viced.h"
#include "host.h"
int eventlog = 0, rxlog = 0;
FILE *debugFile;
-char *logFile = NULL;
+static struct logOptions logopts;
pthread_mutex_t fsync_glock_mutex;
pthread_cond_t fsync_cond;
*/
struct afs_PerfStats afs_perfstats;
-extern int LogLevel;
extern int Statistics;
int busyonrst = 1;
ViceLog(0, ("Vice was last started at %s\n", tbuffer));
#ifdef AFS_DEMAND_ATTACH_FS
- if (LogLevel >= 125) {
+ if (GetLogLevel() >= 125) {
stats_flags = VOL_STATS_PER_CHAIN2;
- } else if (LogLevel >= 25) {
+ } else if (GetLogLevel() >= 25) {
stats_flags = VOL_STATS_PER_CHAIN;
}
VPrintExtendedCacheStats(stats_flags);
OPT_logfile,
OPT_mrafslogs,
OPT_threads,
+#ifdef HAVE_SYSLOG
OPT_syslog,
+#endif
OPT_peer,
OPT_process,
OPT_nojumbo,
CMD_OPTIONAL, "enable MRAFS style logging");
cmd_AddParmAtOffset(opts, OPT_threads, "-p", CMD_SINGLE, CMD_OPTIONAL,
"number of threads");
-#if !defined(AFS_NT40_ENV)
+#ifdef HAVE_SYSLOG
cmd_AddParmAtOffset(opts, OPT_syslog, "-syslog", CMD_SINGLE_OR_FLAG,
CMD_OPTIONAL, "log to syslog");
#endif
optstring = NULL;
}
- cmd_OptionAsInt(opts, OPT_debug, &LogLevel);
- cmd_OptionAsFlag(opts, OPT_mrafslogs, &mrafsStyleLogs);
-
if (cmd_OptionAsInt(opts, OPT_threads, &lwps) == 0) {
lwps_max = max_fileserver_thread() - FILESERVER_HELPER_THREADS;
if (lwps > lwps_max)
lwps = 6;
}
-#ifndef AFS_NT40_ENV
+ /* Logging options. */
+#ifdef HAVE_SYSLOG
if (cmd_OptionPresent(opts, OPT_syslog)) {
- serverLogSyslog = 1;
- cmd_OptionAsInt(opts, OPT_syslog, &serverLogSyslogFacility);
- }
+ if (cmd_OptionPresent(opts, OPT_logfile)) {
+ fprintf(stderr, "Invalid options: -syslog and -logfile are exclusive.\n");
+ return -1;
+ }
+ if (cmd_OptionPresent(opts, OPT_mrafslogs)) {
+ fprintf(stderr, "Invalid options: -syslog and -mrafslogs are exclusive.\n");
+ return -1;
+ }
+
+ logopts.lopt_dest = logDest_syslog;
+ logopts.lopt_facility = LOG_DAEMON;
+ logopts.lopt_tag = "fileserver";
+ cmd_OptionAsInt(opts, OPT_syslog, &logopts.lopt_facility);
+ } else
#endif
+ {
+ logopts.lopt_dest = logDest_file;
+ logopts.lopt_rotateOnOpen = 1;
+ logopts.lopt_rotateStyle = logRotate_old;
+
+ if (cmd_OptionPresent(opts, OPT_logfile))
+ cmd_OptionAsString(opts, OPT_logfile, (char**)&logopts.lopt_filename);
+ else
+ logopts.lopt_filename = AFSDIR_SERVER_FILELOG_FILEPATH;
+
+ if (cmd_OptionPresent(opts, OPT_mrafslogs)) {
+ logopts.lopt_rotateOnReset = 1;
+ logopts.lopt_rotateStyle = logRotate_timestamp;
+ }
+ }
+ cmd_OptionAsInt(opts, OPT_debug, &logopts.lopt_logLevel);
if (cmd_OptionPresent(opts, OPT_peer))
rx_enablePeerRPCStats();
busy_threshold = 3 * rxpackets / 2;
}
- cmd_OptionAsString(opts, OPT_logfile, &logFile);
cmd_OptionAsString(opts, OPT_config, &FS_configPath);
CheckParms();
FS_configPath = strdup(AFSDIR_SERVER_ETC_DIRPATH);
- logFile = strdup(AFSDIR_SERVER_FILELOG_FILEPATH);
+ memset(&logopts, 0, sizeof(logopts));
if (ParseArgs(argc, argv)) {
exit(-1);
/* initialize audit user check */
osi_audit_set_user_check(confDir, fs_IsLocalRealmMatch);
- /* Open FileLog on stdout, stderr, fd 1 and fd2 (for perror), sigh. */
-#ifndef AFS_NT40_ENV
- serverLogSyslogTag = "fileserver";
-#endif
- OpenLog(logFile);
+ OpenLog(&logopts);
LogCommandLine(argc, argv, "starting", "", "File server", FSLog);
if (afsconf_GetLatestKey(confDir, NULL, NULL) == 0) {
void init_sys_error_to_et(void);
/* afsfileprocs.c */
-extern int LogLevel;
extern afs_int32 BlocksSpare;
extern afs_int32 PctSpare;
afs_uint32 wr_HostAddress[MAXSERVERID + 1];
static void *CheckSignal(void*);
-int LogLevel = 0;
int smallMem = 0;
int restrictedQueryLevel = RESTRICTED_QUERY_ANYUSER;
int rxJumbograms = 0; /* default is to not send and receive jumbo grams */
OPT_database,
OPT_logfile,
OPT_threads,
+#ifdef HAVE_SYSLOG
OPT_syslog,
+#endif
OPT_peer,
OPT_process,
OPT_nojumbo,
char clones[MAXHOSTSPERCELL];
afs_uint32 host = ntohl(INADDR_ANY);
struct cmd_syndesc *opts;
+ struct logOptions logopts;
char *vl_dbaseName;
char *configDir;
- char *logFile;
char *auditFileName = NULL;
char *interface = NULL;
#endif
osi_audit_init();
+ memset(&logopts, 0, sizeof(logopts));
+
/* Initialize dirpaths */
if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
#ifdef AFS_NT40_ENV
vl_dbaseName = strdup(AFSDIR_SERVER_VLDB_FILEPATH);
configDir = strdup(AFSDIR_SERVER_ETC_DIRPATH);
- logFile = strdup(AFSDIR_SERVER_VLOG_FILEPATH);
cmd_DisableAbbreviations();
cmd_DisablePositionalCommands();
CMD_OPTIONAL, "location of logfile");
cmd_AddParmAtOffset(opts, OPT_threads, "-p", CMD_SINGLE, CMD_OPTIONAL,
"number of threads");
-#if !defined(AFS_NT40_ENV)
+#ifdef HAVE_SYSLOG
cmd_AddParmAtOffset(opts, OPT_syslog, "-syslog", CMD_SINGLE_OR_FLAG,
CMD_OPTIONAL, "log to syslog");
#endif
free(interface);
}
- cmd_OptionAsInt(opts, OPT_debug, &LogLevel);
cmd_OptionAsString(opts, OPT_database, &vl_dbaseName);
- cmd_OptionAsString(opts, OPT_logfile, &logFile);
if (cmd_OptionAsInt(opts, OPT_threads, &lwps) == 0) {
if (lwps > MAXLWP) {
lwps = MAXLWP;
}
}
-#ifndef AFS_NT40_ENV
+
+ cmd_OptionAsInt(opts, OPT_debug, &logopts.lopt_logLevel);
+#ifdef HAVE_SYSLOG
if (cmd_OptionPresent(opts, OPT_syslog)) {
- serverLogSyslog = 1;
- cmd_OptionAsInt(opts, OPT_syslog, &serverLogSyslogFacility);
- }
+ if (cmd_OptionPresent(opts, OPT_logfile)) {
+ fprintf(stderr, "Invalid options: -syslog and -logfile are exclusive.\n");
+ return -1;
+ }
+
+ logopts.lopt_dest = logDest_syslog;
+ logopts.lopt_facility = LOG_DAEMON; /* default value */
+ logopts.lopt_tag = "vlserver";
+ cmd_OptionAsInt(opts, OPT_syslog, &logopts.lopt_facility);
+ } else
#endif
+ {
+ logopts.lopt_dest = logDest_file;
+ logopts.lopt_rotateOnOpen = 1;
+ logopts.lopt_rotateStyle = logRotate_old;
+
+ if (cmd_OptionPresent(opts, OPT_logfile))
+ cmd_OptionAsString(opts, OPT_logfile, (char**)&logopts.lopt_filename);
+ else
+ logopts.lopt_filename = AFSDIR_SERVER_VLOG_FILEPATH;
+ }
+
/* rx options */
if (cmd_OptionPresent(opts, OPT_peer))
osi_audit_file(auditFileName);
}
-#ifndef AFS_NT40_ENV
- serverLogSyslogTag = "vlserver";
-#endif
- OpenLog(logFile); /* set up logging */
+ OpenLog(&logopts);
#ifdef AFS_PTHREAD_ENV
opr_softsig_Init();
SetupLogSoftSignals();
#ifdef FSSYNC_BUILD_CLIENT
-extern int LogLevel;
-
static SYNC_client_state fssync_state =
{ -1, /* file descriptor */
FSSYNC_ENDPOINT_DECL, /* server endpoint */
static void CallHandler(fd_set * fdsetp);
static void GetHandler(fd_set * fdsetp, int *maxfdp);
#endif
-extern int LogLevel;
static afs_int32 FSYNC_com_VolOp(osi_socket fd, SYNC_command * com, SYNC_response * res);
if (vp) {
if (VVolOpLeaveOnline_r(vp, &info)) {
VUpdateVolume_r(&error, vp, VOL_UPDATE_WAIT); /* At least get volume stats right */
- if (LogLevel) {
+ if (GetLogLevel() > 0) {
Log("FSYNC: Volume %" AFS_VOLID_FMT " (%s) was left on line for an external %s request\n",
afs_printable_VolumeId_lu(V_id(vp)), V_name(vp),
vcom->hdr->reason == V_CLONE ? "clone" :
static void * SalvageChildReaperThread(void *);
static int DoSalvageVolume(struct SalvageQueueNode * node, int slot);
-static void SalvageServer(int argc, char **argv);
+static void SalvageServer(int argc, char **argv, struct logOptions *logopts);
static void SalvageClient(VolumeId vid, char * pname);
static int Reap_Child(char * prog, int * pid, int * status);
VolumeId vid = 0;
struct cmdline_rock *rock = (struct cmdline_rock *)arock;
char *optstring = NULL;
+ struct logOptions logopts;
+
+ memset(&logopts, 0, sizeof(logopts));
#ifdef AFS_SGI_VNODE_GLUE
if (afs_init_kernel_config(-1) < 0) {
free(optstring);
optstring = NULL;
}
-#ifndef AFS_NT40_ENV /* ignore options on NT */
+
+#ifdef HAVE_SYSLOG
if (cmd_OptionPresent(opts, OPT_syslog)) {
- serverLogSyslog = 1;
- }
- cmd_OptionAsInt(opts, OPT_syslogfacility, &serverLogSyslogFacility);
+ if (cmd_OptionPresent(opts, OPT_logfile)) {
+ fprintf(stderr, "Invalid options: -syslog and -logfile are exclusive.\n");
+ return -1;
+ }
+
+ logopts.lopt_dest = logDest_syslog;
+ logopts.lopt_facility = LOG_DAEMON;
+ logopts.lopt_tag = "salvageserver";
+ cmd_OptionAsInt(opts, OPT_syslogfacility, &logopts.lopt_facility);
+ } else
#endif
+ {
+ logopts.lopt_dest = logDest_file;
+ logopts.lopt_rotateOnOpen = 1;
+ logopts.lopt_rotateStyle = logRotate_old;
+
+ if (cmd_OptionPresent(opts, OPT_logfile))
+ cmd_OptionAsString(opts, OPT_logfile, (char**)&logopts.lopt_filename);
+ else
+ logopts.lopt_filename = AFSDIR_SERVER_SALSRVLOG_FILEPATH;
+ }
if (cmd_OptionPresent(opts, OPT_client)) {
if (cmd_OptionAsString(opts, OPT_partition, &optstring) == 0) {
SalvageClient(vid, pname);
} else { /* salvageserver mode */
- SalvageServer(rock->argc, rock->argv);
+ SalvageServer(rock->argc, rock->argv, &logopts);
}
return (0);
}
cmd_AddParmAtOffset(ts, OPT_orphans, "-orphans", CMD_SINGLE, CMD_OPTIONAL,
"ignore | remove | attach");
-#if !defined(AFS_NT40_ENV)
+#ifdef HAVE_SYSLOG
cmd_AddParmAtOffset(ts, OPT_syslog, "-syslog", CMD_FLAG, CMD_OPTIONAL,
"Write salvage log to syslogs");
cmd_AddParmAtOffset(ts, OPT_syslogfacility, "-syslogfacility", CMD_SINGLE,
static int * child_slot;
static void
-SalvageServer(int argc, char **argv)
+SalvageServer(int argc, char **argv, struct logOptions *logopts)
{
int pid, ret;
struct SalvageQueueNode * node;
/* All entries to the log will be appended. Useful if there are
* multiple salvagers appending to the log.
*/
- OpenLog(AFSDIR_SERVER_SALSRVLOG_FILEPATH);
+ OpenLog(logopts);
SetupLogSignals();
Log("%s\n", cml_version_number);
static int
DoSalvageVolume(struct SalvageQueueNode * node, int slot)
{
- char *childLog;
+ char *filename = NULL;
+ struct logOptions logopts;
struct DiskPartition64 * partP;
/* do not allow further forking inside salvager */
* another thread may have held the lock when fork was
* called!
*/
- if (asprintf(&childLog, "%s.%d",
+ memset(&memset, 0, sizeof(logopts));
+ logopts.lopt_dest = logDest_file;
+ logopts.lopt_rotateStyle = logRotate_none;
+ if (asprintf(&filename, "%s.%d",
AFSDIR_SERVER_SLVGLOG_FILEPATH, getpid()) < 0) {
fprintf(stderr, "out of memory\n");
return ENOMEM;
}
- OpenLog(childLog);
- free(childLog);
+ logopts.lopt_filename = filename;
+ OpenLog(&logopts);
+ free(filename);
if (node->command.sop.parent <= 0) {
Log("salvageServer: invalid volume id specified; salvage aborted\n");
pthread_t main_thread;
#endif
-extern char *ShowLogFilename;
extern char cml_version_number[];
static int get_salvage_lock = 0;
char **argv;
};
-#ifndef AFS_NT40_ENV
static int
TimeStampLogFile(char **logfile)
{
lt->tm_min, lt->tm_sec) < 0) {
return ENOMEM;
}
- free(*logfile); /* free the default name */
*logfile = stampSlvgLog;
return 0;
}
-#endif
static int
handleit(struct cmd_syndesc *as, void *arock)
afs_int32 seenpart = 0, seenvol = 0;
VolumeId vid = 0;
ProgramType pt;
- char *logfile = strdup(AFSDIR_SERVER_SLVGLOG_FILEPATH);
#ifdef FAST_RESTART
afs_int32 seenany = 0;
#endif
+ char *filename = NULL;
+ struct logOptions logopts;
VolumePackageOptions opts;
struct DiskPartition64 *partP;
+ memset(&logopts, 0, sizeof(logopts));
+
#ifdef AFS_SGI_VNODE_GLUE
if (afs_init_kernel_config(-1) < 0) {
printf
|| strcmp(ti->data, "a") == 0)
orphans = ORPH_ATTACH;
}
-#ifndef AFS_NT40_ENV /* ignore options on NT */
+
if ((ti = as->parms[16].items)) { /* -syslog */
if (ShowLog) {
fprintf(stderr, "Invalid options: -syslog and -showlog are exclusive.\n");
Exit(1);
}
- serverLogSyslog = 1;
- }
- if ((ti = as->parms[17].items)) { /* -syslogfacility */
- serverLogSyslogFacility = atoi(ti->data);
- }
+ if ((ti = as->parms[18].items)) { /* -datelogs */
+ fprintf(stderr, "Invalid option: -syslog and -datelogs are exclusive.\n");
+ Exit(1);
+ }
+#ifndef HAVE_SYSLOG
+ /* Do not silently ignore. */
+ fprintf(stderr, "Invalid option: -syslog is not available on this platform.\n");
+ Exit(1);
+#else
+ logopts.lopt_dest = logDest_syslog;
+ logopts.lopt_tag = "salvager";
+
+ if ((ti = as->parms[17].items)) /* -syslogfacility */
+ logopts.lopt_facility = atoi(ti->data);
+ else
+ logopts.lopt_facility = LOG_DAEMON; /* default value */
+#endif
+ } else {
+ logopts.lopt_dest = logDest_file;
- if ((ti = as->parms[18].items)) { /* -datelogs */
- int code = TimeStampLogFile(&logfile);
- if (code != 0) {
- fprintf(stderr, "Failed to format log file name for -datelogs; code=%d\n", code);
- Exit(code);
+ if ((ti = as->parms[18].items)) { /* -datelogs */
+ int code = TimeStampLogFile(&filename);
+ if (code != 0) {
+ fprintf(stderr, "Failed to format log file name for -datelogs; code=%d\n", code);
+ Exit(code);
+ }
+ logopts.lopt_filename = filename;
+ } else {
+ logopts.lopt_filename = AFSDIR_SERVER_SLVGLOG_FILEPATH;
}
- ShowLogFilename = logfile;
}
-#endif
- OpenLog(logfile);
+ OpenLog(&logopts);
SetupLogSignals();
+ free(filename); /* Free string created by -datelogs, if one. */
Log("%s\n", cml_version_number);
LogCommandLine(cmdline->argc, cmdline->argv, "SALVAGER", SalvageVersion, "STARTING AFS", Log);
* SALVSYNC is a feature specific to the demand attach fileserver
*/
-extern int LogLevel;
extern int VInit;
extern pthread_mutex_t vol_salvsync_mutex;
static afs_int32 SALVSYNC_com_Link(SALVSYNC_command * com, SALVSYNC_response * res);
-extern int LogLevel;
extern int VInit;
extern pthread_mutex_t vol_salvsync_mutex;
void VNLog(afs_int32 aop, afs_int32 anparms, ... );
-extern int LogLevel;
-
/* logging stuff for finding bugs */
#define THELOGSIZE 5120
static afs_int32 theLog[THELOGSIZE];
Log("VnLoad: Couldn't read vnode %u, volume %" AFS_VOLID_FMT " (%s); volume needs salvage\n", Vn_id(vnp), afs_printable_VolumeId_lu(V_id(vp)), V_name(vp));
} else {
/* vnode is not allocated */
- if (LogLevel >= 5)
+ if (GetLogLevel() >= 5)
Log("VnLoad: Couldn't read vnode %u, volume %" AFS_VOLID_FMT " (%s); read %d bytes, errno %d\n",
Vn_id(vnp), afs_printable_VolumeId_lu(V_id(vp)), V_name(vp), (int)nBytes, errno);
*ec = VNOVNODE;
numjobs++;
} else {
int fd;
- char *logFileName;
+ char *filename;
+ struct logOptions logopts;
+
+ memset(&logopts, 0, sizeof(logopts));
+ logopts.lopt_dest = logDest_file;
for (fd = 0; fd < 16; fd++)
close(fd);
dup2(0, 2);
ShowLog = 0; /* Child processes do not display. */
- if (asprintf(&logFileName, "%s.%d",
+ if (asprintf(&filename, "%s.%d",
AFSDIR_SERVER_SLVGLOG_FILEPATH,
jobs[startjob]->jobnumb) >= 0) {
- OpenLog(logFileName);
- free(logFileName);
+ logopts.lopt_filename = filename;
+ OpenLog(&logopts);
+ free(filename);
}
SalvageFileSys1(jobs[startjob]->partP, 0);
}
} /* while ( thisjob || (!partP && numjobs > 0) ) */
- /* If waited for all jobs to complete, now collect log files and return */
-#ifndef AFS_NT40_ENV
- if (!serverLogSyslog) /* if syslogging - no need to collect */
-#endif
+ /*
+ * If waited for all jobs to complete, now collect log files and return.
+ * No files can be collected when logging to the system log (syslog).
+ */
+ if (GetLogDest() == logDest_file) {
if (!partP) {
char *buf = calloc(1, SALV_BUFFER_SIZE);
char *logFileName;
free(buf);
}
}
-
+ }
return;
}
SalvageShowLog(void)
{
char line[256];
+ char *filename;
FILE *logFile;
if (ShowLog == 0 || ClientMode) {
- return;
- }
-
- if (ShowLogFilename == NULL) {
- ShowLogFilename = strdup(AFSDIR_SERVER_SLVGLOG_FILEPATH);
+ return; /* nothing to do */
}
+ filename = strdup(GetLogFilename());
+ opr_Assert(filename != NULL);
CloseLog();
- logFile = afs_fopen(ShowLogFilename, "r");
+
+ logFile = afs_fopen(filename, "r");
if (!logFile)
printf("Can't read %s, exiting\n", ShowLogFilename);
else {
printf("%s", line);
fflush(stdout);
}
+ free(filename);
}
static void
static Volume * GetVolume(Error * ec, Error * client_ec, VolumeId volumeId,
Volume * hint, const struct timespec *ts);
-int LogLevel; /* Vice loglevel--not defined as extern so that it will be
- * defined when not linked with vice, XXXX */
ProgramType programType; /* The type of program using the package */
static VolumePackageOptions vol_opts;
(*(vp ? nAttached : nUnattached))++;
if (error == VOFFLINE)
Log("Volume %d stays offline (/vice/offline/%s exists)\n", VolumeNumber(dp->d_name), dp->d_name);
- else if (LogLevel >= 5) {
+ else if (GetLogLevel() >= 5) {
Log("Partition %s: attached volume %d (%s)\n",
diskP->name, VolumeNumber(dp->d_name),
dp->d_name);
for (queue_Scan(&VolumeHashTable.Table[i],vp,np,Volume)) {
code = VHold_r(vp);
if (code == 0) {
- if (LogLevel >= 5)
+ if (GetLogLevel() >= 5)
Log("VShutdown: Attempting to take volume %" AFS_VOLID_FMT " offline.\n",
afs_printable_VolumeId_lu(vp->hashid));
VCreateReservation_r(vp);
- if (LogLevel >= 5) {
+ if (GetLogLevel() >= 5) {
Log("VShutdownVolume_r: vid=%" AFS_VOLID_FMT ", device=%d, state=%u\n",
afs_printable_VolumeId_lu(vp->hashid), vp->partition->device,
(unsigned int) V_attachState(vp));
case VOL_STATE_ATTACHED:
code = VHold_r(vp);
if (!code) {
- if (LogLevel >= 5)
+ if (GetLogLevel() >= 5)
Log("VShutdown: Attempting to take volume %" AFS_VOLID_FMT " offline.\n",
afs_printable_VolumeId_lu(vp->hashid));
VLRU_Init_Node_r(vp);
VChangeState_r(vp, VOL_STATE_PREATTACHED);
- if (LogLevel >= 5)
+ if (GetLogLevel() >= 5)
Log("VPreAttachVolumeByVp_r: volume %" AFS_VOLID_FMT " pre-attached\n", afs_printable_VolumeId_lu(vp->hashid));
done:
goto done;
}
}
- if (LogLevel)
+ if (GetLogLevel() != 0)
Log("VOnline: volume %" AFS_VOLID_FMT " (%s) attached and online\n", afs_printable_VolumeId_lu(V_id(vp)),
V_name(vp));
}
goto done;
}
}
- if (LogLevel)
+ if (GetLogLevel() != 0)
Log("VOnline: volume %" AFS_VOLID_FMT " (%s) attached and online\n",
afs_printable_VolumeId_lu(V_id(vp)), V_name(vp));
done:
VGET_CTR_INC(V6);
/* Only log the error if it was a totally unexpected error. Simply
* a missing inode is likely to be caused by the volume being deleted */
- if (errno != ENXIO || LogLevel)
+ if (errno != ENXIO || GetLogLevel() != 0)
Log("Volume %" AFS_VOLID_FMT ": couldn't reread volume header\n",
afs_printable_VolumeId_lu(vp->hashid));
#ifdef AFS_DEMAND_ATTACH_FS
#endif /* AFS_DEMAND_ATTACH_FS */
for(queue_Scan(&vp->rx_call_list, cbv, ncbv, VCallByVol)) {
- if (LogLevel > 0) {
+ if (GetLogLevel() != 0) {
struct rx_peer *peer;
char hoststr[16];
peer = rx_PeerOf(rx_ConnectionOf(cbv->call));
VUpdateVolume_r(&error, vp, 0);
VCloseVolumeHandles_r(vp);
- if (LogLevel) {
+ if (GetLogLevel() != 0) {
if (V_offlineMessage(vp)[0]) {
Log("VOffline: Volume %lu (%s) is now offline (%s)\n",
afs_printable_uint32_lu(V_id(vp)), V_name(vp),
V_inUse(vp) = 0;
VUpdateVolume_r(&error, vp, 0);
VCloseVolumeHandles_r(vp);
- if (LogLevel) {
+ if (GetLogLevel() != 0) {
if (V_offlineMessage(vp)[0]) {
Log("VOffline: Volume %lu (%s) is now offline (%s)\n",
afs_printable_uint32_lu(V_id(vp)), V_name(vp),
/* setup the timing constants */
VLRU_ComputeConstants();
- /* XXX put inside LogLevel check? */
+ /* XXX put inside log level check? */
Log("VLRU: starting scanner with the following configuration parameters:\n");
Log("VLRU: offlining volumes after minimum of %d seconds of inactivity\n", VLRU_offline_thresh);
Log("VLRU: running VLRU soft detach pass every %d seconds\n", VLRU_offline_interval);
int rxJumbograms = 0; /* default is to not send and receive jumbograms. */
int rxMaxMTU = -1;
char *auditFileName = NULL;
-char *logFile = NULL;
+static struct logOptions logopts;
char *configDir = NULL;
#define ADDRSPERSITE 16 /* Same global is in rx/rx_user.c */
OPT_process,
OPT_preserve_vol_stats,
OPT_sync,
+#ifdef HAVE_SYSLOG
OPT_syslog,
+#endif
OPT_logfile,
OPT_config,
OPT_restricted_query
CMD_OPTIONAL, "enable RX RPC statistics");
cmd_AddParmAtOffset(opts, OPT_preserve_vol_stats, "-preserve-vol-stats", CMD_FLAG,
CMD_OPTIONAL, "preserve volume statistics");
-#if !defined(AFS_NT40_ENV)
+#ifdef HAVE_SYSLOG
cmd_AddParmAtOffset(opts, OPT_syslog, "-syslog", CMD_SINGLE_OR_FLAG,
CMD_OPTIONAL, "log to syslog");
#endif
cmd_OptionAsFlag(opts, OPT_rxbind, &rxBind);
cmd_OptionAsFlag(opts, OPT_dotted, &rxkadDisableDotCheck);
cmd_OptionAsFlag(opts, OPT_preserve_vol_stats, &DoPreserveVolumeStats);
- cmd_OptionAsInt(opts, OPT_debug, &LogLevel);
if (cmd_OptionPresent(opts, OPT_peer))
rx_enablePeerRPCStats();
if (cmd_OptionPresent(opts, OPT_process))
rxJumbograms = 0;
if (cmd_OptionPresent(opts, OPT_jumbo))
rxJumbograms = 1;
-#ifndef AFS_NT40_ENV
+
+#ifdef HAVE_SYSLOG
if (cmd_OptionPresent(opts, OPT_syslog)) {
- serverLogSyslog = 1;
- cmd_OptionAsInt(opts, OPT_syslog, &serverLogSyslogFacility);
- }
+ if (cmd_OptionPresent(opts, OPT_logfile)) {
+ fprintf(stderr, "Invalid options: -syslog and -logfile are exclusive.\n");
+ return -1;
+ }
+ logopts.lopt_dest = logDest_syslog;
+ logopts.lopt_facility = LOG_DAEMON;
+ logopts.lopt_tag = "volserver";
+ cmd_OptionAsInt(opts, OPT_syslog, &logopts.lopt_facility);
+ } else
#endif
+ {
+ logopts.lopt_dest = logDest_file;
+ logopts.lopt_rotateOnOpen = 1;
+ logopts.lopt_rotateStyle = logRotate_old;
+
+ if (cmd_OptionPresent(opts, OPT_logfile))
+ cmd_OptionAsString(opts, OPT_logfile, (char**)&logopts.lopt_filename);
+ else
+ logopts.lopt_filename = AFSDIR_SERVER_VOLSERLOG_FILEPATH;
+ }
+ cmd_OptionAsInt(opts, OPT_debug, &logopts.lopt_logLevel);
+
cmd_OptionAsInt(opts, OPT_rxmaxmtu, &rxMaxMTU);
if (cmd_OptionAsInt(opts, OPT_udpsize, &optval) == 0) {
if (optval < rx_GetMinUdpBufSize()) {
return -1;
}
}
- cmd_OptionAsString(opts, OPT_logfile, &logFile);
cmd_OptionAsString(opts, OPT_config, &configDir);
if (cmd_OptionAsString(opts, OPT_restricted_query,
&restricted_query_parameter) == 0) {
}
configDir = strdup(AFSDIR_SERVER_ETC_DIRPATH);
- logFile = strdup(AFSDIR_SERVER_VOLSERLOG_FILEPATH);
if (ParseArgs(argc, argv)) {
exit(1);
exit(1);
}
#endif
- /* Open VolserLog and map stdout, stderr into it; VInitVolumePackage2 can
- log, so we need to do this here */
- OpenLog(logFile);
+
+ OpenLog(&logopts);
VOptDefaults(volumeServer, &opts);
if (VInitVolumePackage2(volumeServer, &opts)) {