logging: add warning if no output module is selected

If no daemon compatible logging module is selected, a message is
displayed to avoid the user to look like mad for messages.
pull/200/merge
Eric Leblond 13 years ago committed by Victor Julien
parent 1c3546fec1
commit 4726e02afb

@ -1373,7 +1373,7 @@ int main(int argc, char **argv)
/* Since our config is now loaded we can finish configurating the /* Since our config is now loaded we can finish configurating the
* logging module. */ * logging module. */
SCLogLoadConfig(); SCLogLoadConfig(daemon);
#ifdef __SC_CUDA_SUPPORT__ #ifdef __SC_CUDA_SUPPORT__
/* load the cuda configuration */ /* load the cuda configuration */

@ -1098,10 +1098,11 @@ void SCLogInitLogModule(SCLogInitData *sc_lid)
return; return;
} }
void SCLogLoadConfig(void) void SCLogLoadConfig(int daemon)
{ {
ConfNode *outputs; ConfNode *outputs;
SCLogInitData *sc_lid; SCLogInitData *sc_lid;
int have_logging = 0;
outputs = ConfGetNode("logging.outputs"); outputs = ConfGetNode("logging.outputs");
if (outputs == NULL) { if (outputs == NULL) {
@ -1178,6 +1179,7 @@ void SCLogLoadConfig(void)
"Logging to file requires a filename"); "Logging to file requires a filename");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
have_logging = 1;
op_iface_ctx = SCLogInitFileOPIface(filename, format, level); op_iface_ctx = SCLogInitFileOPIface(filename, format, level);
} }
else if (strcmp(output->name, "syslog") == 0) { else if (strcmp(output->name, "syslog") == 0) {
@ -1195,6 +1197,7 @@ void SCLogLoadConfig(void)
} }
printf("Initialization syslog logging with format \"%s\".\n", printf("Initialization syslog logging with format \"%s\".\n",
format); format);
have_logging = 1;
op_iface_ctx = SCLogInitSyslogOPIface(facility, format, level); op_iface_ctx = SCLogInitSyslogOPIface(facility, format, level);
} }
else { 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); SCLogInitLogModule(sc_lid);
SCLogDebug("sc_log_global_log_level: %d", sc_log_global_log_level); SCLogDebug("sc_log_global_log_level: %d", sc_log_global_log_level);

@ -546,6 +546,6 @@ int SCLogDebugEnabled(void);
void SCLogRegisterTests(void); void SCLogRegisterTests(void);
void SCLogLoadConfig(void); void SCLogLoadConfig(int daemon);
#endif /* __UTIL_DEBUG_H__ */ #endif /* __UTIL_DEBUG_H__ */

Loading…
Cancel
Save