mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00
Extending the log writer DoInit() API.
We now pass in a Info struct that contains: - the path name (as before) - the rotation interval - the log_rotate_base_time in seconds - a table of key/value pairs with further configuration options. To fill the table, log filters have a new field "config: table[string] of strings". This gives a way to pass arbitrary values from script-land to writers. Interpretation is left up to the writer. Also splits calc_next_rotate() into two functions, one of which is thread-safe and can be used with the log_rotate_base_time value from DoInit(). Includes also updates to the None writer: - It gets its own script writers/none.bro. - New bool option LogNone::debug to enable debug output. It then prints out all the values passed to DoInit(). That's used by a btest test to ensure the new DoInit() values are right. - Fixed a bug that prevented Bro from terminating.. (scripts.base.frameworks.logging.rotate-custom currently fails. Haven't yet investigated why.)
This commit is contained in:
parent
b38d1e1ec2
commit
19eea409c3
16 changed files with 231 additions and 23 deletions
37
testing/btest/scripts/base/frameworks/logging/none-debug.bro
Normal file
37
testing/btest/scripts/base/frameworks/logging/none-debug.bro
Normal file
|
@ -0,0 +1,37 @@
|
|||
#
|
||||
# @TEST-EXEC: bro -b %INPUT >output
|
||||
# @TEST-EXEC: btest-diff output
|
||||
|
||||
redef Log::default_writer = Log::WRITER_NONE;
|
||||
redef LogNone::debug = T;
|
||||
redef Log::default_rotation_interval= 1hr;
|
||||
redef log_rotate_base_time = "00:05";
|
||||
|
||||
module SSH;
|
||||
|
||||
export {
|
||||
redef enum Log::ID += { LOG };
|
||||
|
||||
type Log: record {
|
||||
t: time;
|
||||
id: conn_id; # Will be rolled out into individual columns.
|
||||
status: string &optional;
|
||||
country: string &default="unknown";
|
||||
} &log;
|
||||
}
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
local config: table[string] of string;
|
||||
config["foo"]="bar";
|
||||
config["foo2"]="bar2";
|
||||
|
||||
local cid = [$orig_h=1.2.3.4, $orig_p=1234/tcp, $resp_h=2.3.4.5, $resp_p=80/tcp];
|
||||
|
||||
Log::create_stream(SSH::LOG, [$columns=Log]);
|
||||
|
||||
Log::remove_default_filter(SSH::LOG);
|
||||
Log::add_filter(SSH::LOG, [$name="f1", $exclude=set("t", "id.orig_h"), $config=config]);
|
||||
Log::write(SSH::LOG, [$t=network_time(), $id=cid, $status="success"]);
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue