From: Jason Ish Date: Wed, 2 Oct 2019 22:38:50 +0000 (-0600) Subject: logging: used fixed levels of verbosity for -v, -vv... X-Git-Tag: suricata-5.0.0~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71c53484eea030b4710ddd253d49785ae235aa36;p=thirdparty%2Fsuricata.git logging: used fixed levels of verbosity for -v, -vv... Change the meaning of the verbosity flag to change the log level to fixed levels instead of being relative to whats configured. -v => INFO -vv => PERF -vvv => CONIFG -vvvv => DEBUG But do now allow -v to decrease the verbosity. Bug #1851 --- diff --git a/src/util-debug.c b/src/util-debug.c index aea8be7400..33185f99d9 100644 --- a/src/util-debug.c +++ b/src/util-debug.c @@ -1299,6 +1299,13 @@ void SCLogLoadConfig(int daemon, int verbose) 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) { @@ -1315,24 +1322,17 @@ void SCLogLoadConfig(int daemon, int verbose) /* 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) @@ -1389,6 +1389,9 @@ void SCLogLoadConfig(int daemon, int verbose) 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); }