mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00

* topic/robin/rotation-pp: Adding a default_path_func that makes the default naming scheme script-level controlled. Reworking logging's postprocessor logic. Conflicts: scripts/base/frameworks/logging/main.bro testing/btest/policy/frameworks/logging/rotate-custom.bro
43 lines
1.1 KiB
Text
43 lines
1.1 KiB
Text
#
|
|
# @TEST-EXEC: bro -b -r %DIR/rotation.trace %INPUT 2>&1 | egrep "test|test2" | sort >out
|
|
# @TEST-EXEC: for i in `ls test*.log | sort`; do printf '> %s\n' $i; cat $i; done | sort | uniq >>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_cmd = "echo 1st";
|
|
|
|
function custom_rotate(info: Log::RotationInfo) : bool
|
|
{
|
|
print "custom rotate", info;
|
|
return T;
|
|
}
|
|
|
|
redef Log::rotation_control += {
|
|
[Log::WRITER_ASCII, "test2"] = [$interv=30mins, $postprocessor=custom_rotate]
|
|
};
|
|
|
|
event bro_init()
|
|
{
|
|
Log::create_stream(Test, [$columns=Log]);
|
|
Log::add_filter(Test, [$name="2nd", $path="test2"]);
|
|
|
|
}
|
|
|
|
event new_connection(c: connection)
|
|
{
|
|
Log::write(Test, [$t=network_time(), $id=c$id]);
|
|
}
|