zeek/testing/btest/scripts/base/frameworks/logging/rotate-pp-env.zeek
Arne Welzel d89f16dfc9 logging: Support rotation_postprocessor_command_env
This new table provides a mechanism to add environment variables to the
postprocessor execution. Use case is from ZeekControl to inject a suffix
to be used when running with multiple logger.
2023-04-17 13:10:14 +00:00

32 lines
758 B
Text

# @TEST-DOC: Using a custom environment for the postprocessor command.
# @TEST-EXEC: ZEEK_ARG_EXTERNAL=external zeek -b -r ${TRACES}/rotation.trace %INPUT >out 2>&1
# @TEST-EXEC: btest-diff out
module Test;
export {
redef enum Log::ID += { LOG };
type Log: record {
t: time;
id: conn_id;
} &log;
}
redef Log::default_rotation_interval = 1hr;
redef Log::default_rotation_postprocessor_cmd = "env | grep ZEEK_ARG | sort; true ";
redef Log::default_rotation_postprocessor_cmd_env += {
["REDEF"] = "redef",
};
event zeek_init()
{
Log::create_stream(Test::LOG, [$columns=Log]);
Log::default_rotation_postprocessor_cmd_env["INIT"] = "zeek_init";
}
event new_connection(c: connection)
{
Log::write(Test::LOG, [$t=network_time(), $id=c$id]);
}