suricata: add -v[v] option to increase verbosity

This patch adds a -v option to suricata. It increases the log level
defined in the YAML.
pull/576/head
Eric Leblond 12 years ago
parent 4a4600539d
commit 2be194d03f

@ -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();

@ -154,6 +154,7 @@ typedef struct SCInstance_ {
int rule_reload;
int daemon;
int offline;
int verbose;
struct timeval start_time;

@ -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;

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

Loading…
Cancel
Save