mirror of
https://github.com/zeek/zeek.git
synced 2025-10-16 21:48:21 +00:00
bro -B <x> now supports "all" and "help" for <x>.
"all" enables all debug streams. "help" prints a list of available debug streams. Based on patch by John Donnelly. BIT-1313 #merged
This commit is contained in:
parent
1d49ec63f8
commit
1dbc5ed523
6 changed files with 86 additions and 12 deletions
|
@ -55,32 +55,81 @@ DebugLogger::~DebugLogger()
|
|||
fclose(file);
|
||||
}
|
||||
|
||||
void DebugLogger::ShowStreamsHelp()
|
||||
{
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "Enable debug output into debug.log with -B <streams>.\n");
|
||||
fprintf(stderr, "<streams> is a comma-separated list of streams to enable.\n");
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "Available streams:\n");
|
||||
|
||||
for ( int i = 0; i < NUM_DBGS; ++i )
|
||||
fprintf(stderr," %s\n", streams[i].prefix);
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, " plugin-<plugin-name> (replace '::' in name with '-'; e.g., '-B plugin-Bro-Netmap')\n");
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "Pseudo streams\n");
|
||||
fprintf(stderr, " verbose Increase verbosity.\n");
|
||||
fprintf(stderr, " all Enable all streams at maximum verbosity.\n");
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
void DebugLogger::EnableStreams(const char* s)
|
||||
{
|
||||
char* tmp = copy_string(s);
|
||||
char* brkt;
|
||||
char* tmp = copy_string(s);
|
||||
char* tok = strtok(tmp, ",");
|
||||
|
||||
while ( tok )
|
||||
{
|
||||
if ( strcasecmp("all", tok) == 0 )
|
||||
{
|
||||
for ( int i = 0; i < NUM_DBGS; ++i )
|
||||
{
|
||||
streams[i].enabled = true;
|
||||
enabled_streams.insert(streams[i].prefix);
|
||||
}
|
||||
|
||||
verbose = true;
|
||||
goto next;
|
||||
}
|
||||
|
||||
if ( strcasecmp("verbose", tok) == 0 )
|
||||
{
|
||||
verbose = true;
|
||||
goto next;
|
||||
}
|
||||
|
||||
if ( strcasecmp("help", tok) == 0 )
|
||||
{
|
||||
ShowStreamsHelp();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ( strncmp(tok, "plugin-", strlen("plugin-")) == 0 )
|
||||
{
|
||||
// Cannot verify this at this time, plugins may not
|
||||
// have been loaded.
|
||||
enabled_streams.insert(tok);
|
||||
goto next;
|
||||
}
|
||||
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < NUM_DBGS; ++i )
|
||||
{
|
||||
if ( strcasecmp(streams[i].prefix, tok) == 0 )
|
||||
{
|
||||
streams[i].enabled = true;
|
||||
break;
|
||||
enabled_streams.insert(tok);
|
||||
goto next;
|
||||
}
|
||||
|
||||
if ( i == NUM_DBGS )
|
||||
{
|
||||
if ( strcasecmp("verbose", tok) == 0 )
|
||||
verbose = true;
|
||||
else if ( strncmp(tok, "plugin-", 7) != 0 )
|
||||
reporter->FatalError("unknown debug stream %s\n", tok);
|
||||
}
|
||||
|
||||
enabled_streams.insert(tok);
|
||||
reporter->FatalError("unknown debug stream '%s', try -B help.\n", tok);
|
||||
|
||||
next:
|
||||
tok = strtok(0, ",");
|
||||
}
|
||||
|
||||
|
|
|
@ -78,6 +78,8 @@ public:
|
|||
void SetVerbose(bool arg_verbose) { verbose = arg_verbose; }
|
||||
bool IsVerbose() const { return verbose; }
|
||||
|
||||
void ShowStreamsHelp();
|
||||
|
||||
private:
|
||||
FILE* file;
|
||||
bool verbose;
|
||||
|
|
|
@ -188,7 +188,7 @@ void usage()
|
|||
fprintf(stderr, " -x|--print-state <file.bst> | print contents of state file\n");
|
||||
fprintf(stderr, " -z|--analyze <analysis> | run the specified policy file analysis\n");
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " -B|--debug <dbgstreams> | Enable debugging output for selected streams\n");
|
||||
fprintf(stderr, " -B|--debug <dbgstreams> | Enable debugging output for selected streams ('-B help' for help)\n");
|
||||
#endif
|
||||
fprintf(stderr, " -C|--no-checksums | ignore checksums\n");
|
||||
fprintf(stderr, " -D|--dfa-size <size> | DFA state cache size\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue