mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 16:48:19 +00:00
Merge branch 'topic/robin/event-dumper'
Changes: - Changing semantics of the new_event() meta event: it's raised only for events that have a handler defined. There are too many checks in Bro that prevent events wo/ handler from being even prepared to raise to do that differently. - Adding test case. * topic/robin/event-dumper: New script misc/dump-events.bro, along with core support, that dumps events Bro is raising in an easily readable form. Prettyfing Describe() for record types.
This commit is contained in:
commit
dadfcde70e
14 changed files with 420 additions and 8 deletions
40
scripts/policy/misc/dump-events.bro
Normal file
40
scripts/policy/misc/dump-events.bro
Normal file
|
@ -0,0 +1,40 @@
|
|||
##! This script dumps the events that Bro raises out to standard output in a
|
||||
##! readable form. This is for debugging only and allows to understand events and
|
||||
##! their parameters as Bro processes input. Note that it will show only events
|
||||
##! for which a handler is defined.
|
||||
|
||||
module DumpEvents;
|
||||
|
||||
export {
|
||||
## If true, include event arguments in output.
|
||||
const include_args = T &redef;
|
||||
|
||||
## Only include events matching the given pattern into output. By default, the
|
||||
## pattern matches all events.
|
||||
const include = /.*/ &redef;
|
||||
}
|
||||
|
||||
event new_event(name: string, args: call_argument_vector)
|
||||
{
|
||||
if ( include !in name )
|
||||
return;
|
||||
|
||||
print fmt("%17.6f %s", network_time(), name);
|
||||
|
||||
if ( ! include_args || |args| == 0 )
|
||||
return;
|
||||
|
||||
for ( i in args )
|
||||
{
|
||||
local a = args[i];
|
||||
|
||||
local proto = fmt("%s: %s", a$name, a$type_name);
|
||||
|
||||
if ( a?$value )
|
||||
print fmt(" [%d] %-18s = %s", i, proto, a$value);
|
||||
else
|
||||
print fmt(" | %-18s = %s [default]", proto, a$value);
|
||||
}
|
||||
|
||||
print "";
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue