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

This follows rather closely how rotation currently works in rotate-logs.bro. logging.bro now defines: # Default rotation interval; zero disables rotation. const default_rotation_interval = 0secs &redef; # Default naming suffix format. const default_rotation_date_format = "%y-%m-%d_%H.%M.%S" &redef; # Default postprocessor for writers outputting into files. const default_rotation_postprocessor = "" &redef; # Default function to construct the name of the rotated file. # The default implementation includes # default_rotation_date_format into the file name. global default_rotation_path_func: function(info: RotationInfo) : string &redef; Writer support for rotation is optional, usually it will only make sense for file-based writers. TODO: Currently, there's no way to customize rotation on a per file basis, there are only the global defaults as described above. Individual customization is coming next.
31 lines
739 B
Text
31 lines
739 B
Text
#
|
|
# @TEST-EXEC: bro -r %DIR/rotation.trace %INPUT >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.
|
|
};
|
|
}
|
|
|
|
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]);
|
|
}
|