From b58ff2b8d879d63476373056b166f72da56b5f5d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Sun, 20 Jun 2010 22:28:28 +0000 Subject: [PATCH] * vCtdlLogPrintf(): if we are running as deamon, and don't syslog but specified -x, we want a logfile. --- citadel/server_main.c | 5 +++++ citadel/sysdep.c | 4 ++-- citadel/sysdep_decls.h | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/citadel/server_main.c b/citadel/server_main.c index bdcdac46e..9a425a0fb 100644 --- a/citadel/server_main.c +++ b/citadel/server_main.c @@ -106,6 +106,7 @@ int main(int argc, char **argv) int relh=0; int home=0; int dbg=0; + int have_minus_x=0; char relhome[PATH_MAX]=""; char ctdldir[PATH_MAX]=CTDLDIR; #ifdef HAVE_RUN_DIR @@ -142,6 +143,8 @@ int main(int argc, char **argv) /* run in the background if -d was specified */ else if (!strcmp(argv[a], "-d")) { running_as_daemon = 1; + if (!have_minus_x) + print_to_logfile = 0; } /* run a few stats if -s was specified */ @@ -152,6 +155,8 @@ int main(int argc, char **argv) /* -x specifies the desired logging level */ else if (!strncmp(argv[a], "-x", 2)) { verbosity = atoi(&argv[a][2]); + have_minus_x = 1; + print_to_logfile = 1; } else if (!strncmp(argv[a], "-h", 2)) { diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 2625d615d..963af9df6 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -93,7 +93,7 @@ int verbosity = DEFAULT_VERBOSITY; /* Logging level */ int syslog_facility = LOG_DAEMON; int enable_syslog = 0; - +int print_to_logfile = 1; /* * CtdlLogPrintf() ... Write logging information @@ -113,7 +113,7 @@ void vCtdlLogPrintf(enum LogLevel loglevel, const char *format, va_list arg_ptr) } /* stderr output code */ - if (enable_syslog || running_as_daemon) return; + if (enable_syslog || !print_to_logfile) return; /* if we run in forground and syslog is disabled, log to terminal */ if (loglevel <= verbosity) { diff --git a/citadel/sysdep_decls.h b/citadel/sysdep_decls.h index df25cbf94..3eaccf20f 100644 --- a/citadel/sysdep_decls.h +++ b/citadel/sysdep_decls.h @@ -52,6 +52,7 @@ void CtdlLogPrintf(enum LogLevel loglevel, const char *format, ...); void vCtdlLogPrintf (enum LogLevel loglevel, const char *format, va_list arg_ptr); extern int enable_syslog; +extern int print_to_logfile; void init_sysdep (void); int ig_tcp_server (char *ip_addr, int port_number, int queue_len,char **errormessage); -- 2.30.2