mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Sort streams in "-B help" output, and match case-insensitively throughout
Matching of plugins' debug streams was still case-sensitive. Also contains some minor output tweaks. It'd be nice to only list plugin debug streams actually _used_ by plugins. I didn't see a quick way to do that so that's for another time.
This commit is contained in:
parent
b4ddf73e22
commit
5e4942bcc0
4 changed files with 23 additions and 13 deletions
|
@ -53,21 +53,28 @@ void DebugLogger::OpenDebugLog(const char* filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugLogger::ShowStreamsHelp() {
|
void DebugLogger::ShowStreamsHelp() {
|
||||||
fprintf(stderr, "\n");
|
|
||||||
fprintf(stderr, "Enable debug output into debug.log with -B <streams>.\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, "<streams> is a case-insensitive, comma-separated list of streams to enable:\n");
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
fprintf(stderr, "Available streams:\n");
|
|
||||||
|
|
||||||
for ( int i = 0; i < NUM_DBGS; ++i )
|
std::vector<std::string> prefixes;
|
||||||
fprintf(stderr, " %s\n", streams[i].prefix);
|
|
||||||
|
|
||||||
|
for ( const auto& stream : streams )
|
||||||
|
prefixes.emplace_back(stream.prefix);
|
||||||
|
std::sort(prefixes.begin(), prefixes.end());
|
||||||
|
|
||||||
|
for ( const auto& prefix : prefixes )
|
||||||
|
fprintf(stderr, " %s\n", prefix.c_str());
|
||||||
|
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
fprintf(stderr, "Every plugin (see -N) also has its own debug stream:\n");
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
" plugin-<plugin-name> (replace '::' in name with '-'; e.g., '-B "
|
" plugin-<plugin-name> (replace '::' in name with '-'; e.g., '-B "
|
||||||
"plugin-Zeek-Netmap')\n");
|
"plugin-Zeek-JavaScript')\n");
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
fprintf(stderr, "Pseudo streams:\n");
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
fprintf(stderr, "Pseudo streams\n");
|
|
||||||
fprintf(stderr, " verbose Increase verbosity.\n");
|
fprintf(stderr, " verbose Increase verbosity.\n");
|
||||||
fprintf(stderr, " all Enable all streams at maximum verbosity.\n");
|
fprintf(stderr, " all Enable all streams at maximum verbosity.\n");
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
|
@ -79,6 +86,8 @@ void DebugLogger::EnableStreams(const char* s) {
|
||||||
char* tok = strtok(tmp, ",");
|
char* tok = strtok(tmp, ",");
|
||||||
|
|
||||||
while ( tok ) {
|
while ( tok ) {
|
||||||
|
std::string ltok{util::strtolower(tok)};
|
||||||
|
|
||||||
if ( strcasecmp("all", tok) == 0 ) {
|
if ( strcasecmp("all", tok) == 0 ) {
|
||||||
for ( int i = 0; i < NUM_DBGS; ++i ) {
|
for ( int i = 0; i < NUM_DBGS; ++i ) {
|
||||||
streams[i].enabled = true;
|
streams[i].enabled = true;
|
||||||
|
@ -99,10 +108,10 @@ void DebugLogger::EnableStreams(const char* s) {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( util::starts_with(tok, "plugin-") ) {
|
if ( util::starts_with(ltok, "plugin-") ) {
|
||||||
// Cannot verify this at this time, plugins may not
|
// Cannot verify this at this time, plugins may not
|
||||||
// have been loaded.
|
// have been loaded.
|
||||||
enabled_streams.insert(tok);
|
enabled_streams.insert(ltok);
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +120,7 @@ void DebugLogger::EnableStreams(const char* s) {
|
||||||
for ( i = 0; i < NUM_DBGS; ++i ) {
|
for ( i = 0; i < NUM_DBGS; ++i ) {
|
||||||
if ( strcasecmp(streams[i].prefix, tok) == 0 ) {
|
if ( strcasecmp(streams[i].prefix, tok) == 0 ) {
|
||||||
streams[i].enabled = true;
|
streams[i].enabled = true;
|
||||||
enabled_streams.insert(tok);
|
enabled_streams.insert(ltok);
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ private:
|
||||||
static Stream streams[NUM_DBGS];
|
static Stream streams[NUM_DBGS];
|
||||||
|
|
||||||
const std::string PluginStreamName(const std::string& plugin_name) {
|
const std::string PluginStreamName(const std::string& plugin_name) {
|
||||||
return "plugin-" + util::strreplace(plugin_name, "::", "-");
|
return "plugin-" + util::strtolower(util::strreplace(plugin_name, "::", "-"));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
error in <command line>, line 3: No plugin debug stream 'plugin-zeek-http' found
|
error in <command line>, line 3: No plugin debug stream 'plugin-notaplugin' found
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
# @TEST-REQUIRES: test "$($BUILD/zeek-config --build_type)" = "debug"
|
# @TEST-REQUIRES: test "$($BUILD/zeek-config --build_type)" = "debug"
|
||||||
|
|
||||||
# @TEST-EXEC: zeek -B plugin-Zeek-HTTP -e 'event zeek_init() { print "zeek_init"; }' 2>zeek.stderr
|
# @TEST-EXEC: zeek -B plugin-Zeek-HTTP -e 'event zeek_init() { print "zeek_init"; }' 2>zeek.stderr
|
||||||
# @TEST-EXEC-FAIL: zeek -B plugin-zeek-http -e 'event zeek_init() { print "zeek_init"; }' 2>zeek.stderr
|
# @TEST-EXEC: zeek -B PLUGIN-zeek-http -e 'event zeek_init() { print "zeek_init"; }' 2>zeek.stderr
|
||||||
|
# @TEST-EXEC-FAIL: zeek -B plugin-notaplugin -e 'event zeek_init() { print "zeek_init"; }' 2>zeek.stderr
|
||||||
|
|
||||||
# @TEST-EXEC: btest-diff zeek.stderr
|
# @TEST-EXEC: btest-diff zeek.stderr
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue