* vCtdlLogPrintf(): if we are running as deamon, and don't syslog but specified ...
authorWilfried Göesgens <willi@citadel.org>
Sun, 20 Jun 2010 22:28:28 +0000 (22:28 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 20 Jun 2010 22:28:28 +0000 (22:28 +0000)
citadel/server_main.c
citadel/sysdep.c
citadel/sysdep_decls.h

index bdcdac46ed264fdeaf3b1f4bd31733560492235c..9a425a0fb907a4dee1cafe3d7105e859a799073b 100644 (file)
@@ -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)) {
index 2625d615d2fd5ab38c9a6beaae2ec53084a53d29..963af9df6aa84e3d081182cb9d954e51136d93f6 100644 (file)
@@ -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) { 
index df25cbf9454c3157a5b53108d6f9804172f5461e..3eaccf20f5762dbbf1355c289431251f3a4337e7 100644 (file)
@@ -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);