SCLogInitData *sc_lid;
int have_logging = 0;
int max_level = 0;
+ SCLogLevel min_level = 0;
+
+ /* If verbose logging was requested, set the minimum as
+ * SC_LOG_NOTICE plus the extra verbosity. */
+ if (verbose) {
+ min_level = SC_LOG_NOTICE + verbose;
+ }
outputs = ConfGetNode("logging.outputs");
if (outputs == NULL) {
/* Get default log level and format. */
const char *default_log_level_s = NULL;
if (ConfGet("logging.default-log-level", &default_log_level_s) == 1) {
- sc_lid->global_log_level =
+ SCLogLevel default_log_level =
SCMapEnumNameToValue(default_log_level_s, sc_log_level_map);
- if (sc_lid->global_log_level == -1) {
+ if (default_log_level == -1) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid default log level: %s",
default_log_level_s);
exit(EXIT_FAILURE);
}
+ sc_lid->global_log_level = MAX(min_level, default_log_level);
}
else {
- SCLogWarning(SC_ERR_MISSING_CONFIG_PARAM,
- "No default log level set, will use notice.");
- sc_lid->global_log_level = SC_LOG_NOTICE;
- }
-
- if (verbose) {
- sc_lid->global_log_level += verbose;
- if (sc_lid->global_log_level > SC_LOG_LEVEL_MAX)
- sc_lid->global_log_level = SC_LOG_LEVEL_MAX;
+ sc_lid->global_log_level = MAX(min_level, SC_LOG_NOTICE);
}
if (ConfGet("logging.default-log-format", &sc_lid->global_log_format) != 1)
max_level = MAX(max_level, level);
}
+ /* Increase the level of extra verbosity was requested. */
+ level = MAX(min_level, level);
+
if (strcmp(output->name, "console") == 0) {
op_iface_ctx = SCLogInitConsoleOPIface(format, level, type);
}