diff --git a/src/suricata.c b/src/suricata.c index c3ae657106..1e75dee94a 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -492,6 +492,7 @@ void usage(const char *progname) printf("\t--service-change-params : change service startup parameters\n"); #endif /* OS_WIN32 */ printf("\t-V : display Suricata version\n"); + printf("\t-v[v] : increase default Suricata verbosity\n"); #ifdef UNITTESTS printf("\t-u : run the unittests and exit\n"); printf("\t-U, --unittest-filter=REGEX : filter unittests with a regex\n"); @@ -904,6 +905,7 @@ static void SCInstanceInit(SCInstance *suri) suri->delayed_detect = 0; suri->daemon = 0; suri->offline = 0; + suri->verbose = 0; } static TmEcode PrintVersion() @@ -1011,7 +1013,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri) /* getopt_long stores the option index here. */ int option_index = 0; - char short_opts[] = "c:TDhi:l:q:d:r:us:S:U:VF:"; + char short_opts[] = "c:TDhi:l:q:d:r:us:S:U:VF:v"; while ((opt = getopt_long(argc, argv, short_opts, long_opts, &option_index)) != -1) { switch (opt) { @@ -1471,6 +1473,9 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri) SetBpfStringFromFile(optarg); break; + case 'v': + suri->verbose++; + break; default: usage(argv[0]); return TM_ECODE_FAILED; @@ -1894,7 +1899,7 @@ int main(int argc, char **argv) /* Since our config is now loaded we can finish configurating the * logging module. */ - SCLogLoadConfig(suri.daemon); + SCLogLoadConfig(suri.daemon, suri.verbose); SCPrintVersion(); diff --git a/src/suricata.h b/src/suricata.h index d6b02411ed..551013c7eb 100644 --- a/src/suricata.h +++ b/src/suricata.h @@ -154,6 +154,7 @@ typedef struct SCInstance_ { int rule_reload; int daemon; int offline; + int verbose; struct timeval start_time; diff --git a/src/util-debug.c b/src/util-debug.c index 82d7b34e4f..ef05fafafd 100644 --- a/src/util-debug.c +++ b/src/util-debug.c @@ -1098,7 +1098,7 @@ void SCLogInitLogModule(SCLogInitData *sc_lid) return; } -void SCLogLoadConfig(int daemon) +void SCLogLoadConfig(int daemon, int verbose) { ConfNode *outputs; SCLogInitData *sc_lid; @@ -1132,6 +1132,13 @@ void SCLogLoadConfig(int daemon) "No default log level set, will use info."); 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; + } + if (ConfGet("logging.default-log-format", &sc_lid->global_log_format) != 1) sc_lid->global_log_format = SC_LOG_DEF_LOG_FORMAT; diff --git a/src/util-debug.h b/src/util-debug.h index a778b98fd6..e5b4d70550 100644 --- a/src/util-debug.h +++ b/src/util-debug.h @@ -546,6 +546,6 @@ int SCLogDebugEnabled(void); void SCLogRegisterTests(void); -void SCLogLoadConfig(int daemon); +void SCLogLoadConfig(int daemon, int verbose); #endif /* __UTIL_DEBUG_H__ */