zeek/testing/btest/logging/rotate.bro
Jon Siwek 83ffca5a4a Fix logging rotation tests.
By filtering the rotation output from Bro to weed out log streams
that the unit test didn't create (default logging streams).
2011-06-20 13:37:04 -05:00

31 lines
758 B
Text

#
# @TEST-EXEC: bro -r %DIR/rotation.trace %INPUT | grep "test" >out
# @TEST-EXEC: for i in test-*.log; do printf '> %s\n' $i; cat $i; done >>out
# @TEST-EXEC: btest-diff out
module Test;
export {
# Create a new ID for our log stream
redef enum Log::ID += { Test };
# Define a record with all the columns the log file can have.
# (I'm using a subset of fields from ssh-ext for demonstration.)
type Log: record {
t: time;
id: conn_id; # Will be rolled out into individual columns.
} &log;
}
redef Log::default_rotation_interval = 1hr;
redef Log::default_rotation_postprocessor = "echo";
event bro_init()
{
Log::create_stream(Test, [$columns=Log]);
}
event new_connection(c: connection)
{
Log::write(Test, [$t=network_time(), $id=c$id]);
}