mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00
Make "-B all" apply to plugin streams as well.
This commit is contained in:
parent
5e4942bcc0
commit
7563af4906
3 changed files with 20 additions and 10 deletions
|
@ -21,11 +21,6 @@ DebugLogger::Stream DebugLogger::streams[NUM_DBGS] =
|
|||
{"plugins", 0, false}, {"zeekygen", 0, false}, {"pktio", 0, false}, {"broker", 0, false},
|
||||
{"scripts", 0, false}, {"supervisor", 0, false}, {"hashkey", 0, false}, {"spicy", 0, false}};
|
||||
|
||||
DebugLogger::DebugLogger() {
|
||||
verbose = false;
|
||||
file = nullptr;
|
||||
}
|
||||
|
||||
DebugLogger::~DebugLogger() {
|
||||
if ( file && file != stderr )
|
||||
fclose(file);
|
||||
|
@ -94,6 +89,7 @@ void DebugLogger::EnableStreams(const char* s) {
|
|||
enabled_streams.insert(streams[i].prefix);
|
||||
}
|
||||
|
||||
all = true;
|
||||
verbose = true;
|
||||
goto next;
|
||||
}
|
||||
|
@ -175,10 +171,11 @@ void DebugLogger::Log(DebugStream stream, const char* fmt, ...) {
|
|||
}
|
||||
|
||||
void DebugLogger::Log(const plugin::Plugin& plugin, const char* fmt, ...) {
|
||||
if ( ! all ) {
|
||||
std::string tok = PluginStreamName(plugin.Name());
|
||||
|
||||
if ( enabled_streams.find(tok) == enabled_streams.end() )
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(file, "%17.06f/%17.06f [plugin %s] ", run_state::network_time, util::current_time(true),
|
||||
plugin.Name().c_str());
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace detail {
|
|||
class DebugLogger {
|
||||
public:
|
||||
// Output goes to stderr per default.
|
||||
DebugLogger();
|
||||
DebugLogger() : file(nullptr), all(false), verbose(false) {};
|
||||
~DebugLogger();
|
||||
|
||||
void OpenDebugLog(const char* filename = 0);
|
||||
|
@ -95,6 +95,7 @@ public:
|
|||
|
||||
private:
|
||||
FILE* file;
|
||||
bool all;
|
||||
bool verbose;
|
||||
|
||||
struct Stream {
|
||||
|
|
12
testing/btest/plugins/debug-streams-all.js
Normal file
12
testing/btest/plugins/debug-streams-all.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* Verify that `-B all` leads to plugin debug stream content in debug.log.
|
||||
* This requires JavaScript and a debug build.
|
||||
* @TEST-REQUIRES: test "$($BUILD/zeek-config --build_type)" = "debug"
|
||||
* @TEST-REQUIRES: $SCRIPTS/have-javascript
|
||||
* @TEST-EXEC: zeek -b -B all %INPUT
|
||||
* @TEST-EXEC: grep -q '[plugin Zeek::JavaScript]' debug.log
|
||||
*/
|
||||
|
||||
zeek.on('zeek_init', () => {
|
||||
console.log('Hello Zeek!');
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue