]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
logging: add warning if no output module is selected
authorEric Leblond <eric@regit.org>
Sun, 11 Nov 2012 19:59:27 +0000 (20:59 +0100)
committerVictor Julien <victor@inliniac.net>
Wed, 14 Nov 2012 09:29:49 +0000 (10:29 +0100)
If no daemon compatible logging module is selected, a message is
displayed to avoid the user to look like mad for messages.

src/suricata.c
src/util-debug.c
src/util-debug.h

index b5e7e738663f092e524fd9ea8c801c1b182de67e..ac89f13a062b97b512e784d951a62acc8a43ebe7 100644 (file)
@@ -1373,7 +1373,7 @@ int main(int argc, char **argv)
 
     /* Since our config is now loaded we can finish configurating the
      * logging module. */
-    SCLogLoadConfig();
+    SCLogLoadConfig(daemon);
 
 #ifdef __SC_CUDA_SUPPORT__
     /* load the cuda configuration */
index 378d01184d81b6b457fdcc03c0eb94d9dd75ae97..572690e8001d69932f7f275842064ffe97a07aa5 100644 (file)
@@ -1098,10 +1098,11 @@ void SCLogInitLogModule(SCLogInitData *sc_lid)
     return;
 }
 
-void SCLogLoadConfig(void)
+void SCLogLoadConfig(int daemon)
 {
     ConfNode *outputs;
     SCLogInitData *sc_lid;
+    int have_logging = 0;
 
     outputs = ConfGetNode("logging.outputs");
     if (outputs == NULL) {
@@ -1178,6 +1179,7 @@ void SCLogLoadConfig(void)
                     "Logging to file requires a filename");
                 exit(EXIT_FAILURE);
             }
+            have_logging = 1;
             op_iface_ctx = SCLogInitFileOPIface(filename, format, level);
         }
         else if (strcmp(output->name, "syslog") == 0) {
@@ -1195,6 +1197,7 @@ void SCLogLoadConfig(void)
             }
             printf("Initialization syslog logging with format \"%s\".\n",
                 format);
+            have_logging = 1;
             op_iface_ctx = SCLogInitSyslogOPIface(facility, format, level);
         }
         else {
@@ -1206,6 +1209,13 @@ void SCLogLoadConfig(void)
         }
     }
 
+    if (daemon && (have_logging == 0)) {
+        SCLogError(SC_ERR_MISSING_CONFIG_PARAM,
+                   "NO logging compatible with daemon mode selected,"
+                   " suricata won't be able to log. Please update "
+                   " 'logging.outputs' in the YAML.");
+    }
+
     SCLogInitLogModule(sc_lid);
 
     SCLogDebug("sc_log_global_log_level: %d", sc_log_global_log_level);
index 0d98d429c245daef2399a4cce5255970aa4727b7..a778b98fd6d698568e008133094689eb3a4de17e 100644 (file)
@@ -546,6 +546,6 @@ int SCLogDebugEnabled(void);
 
 void SCLogRegisterTests(void);
 
-void SCLogLoadConfig(void);
+void SCLogLoadConfig(int daemon);
 
 #endif /* __UTIL_DEBUG_H__ */