mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 18:18:19 +00:00
logging: Better error messages for invalid Log::delay() calls
Add a test for Log::delay() usage within filter policy hooks, too.
This commit is contained in:
parent
5e046eee58
commit
e2ce929fa4
6 changed files with 29 additions and 7 deletions
|
@ -5,10 +5,17 @@
|
|||
|
||||
redef enum Log::ID += { LOG };
|
||||
|
||||
type Info: record {
|
||||
ts: time &log &default=network_time();
|
||||
};
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
# Not within a log write
|
||||
Log::delay(LOG, []);
|
||||
# Log::delay() not within a Log::log_stream_policy hook
|
||||
Log::create_stream(LOG, [$columns=Info]);
|
||||
local rec = Info();
|
||||
local token = Log::delay(LOG, rec);
|
||||
Log::delay_finish(LOG, rec, token);
|
||||
}
|
||||
|
||||
@TEST-START-NEXT
|
||||
|
@ -50,3 +57,13 @@ hook Log::log_stream_policy(rec: Conn::Info, id: Log::ID)
|
|||
Log::delay_finish(id, rec, token);
|
||||
Log::delay_finish(id, rec, token);
|
||||
}
|
||||
|
||||
@TEST-START-NEXT
|
||||
@load base/protocols/conn
|
||||
|
||||
hook Conn::log_policy(rec: Conn::Info, id: Log::ID, filter: Log::Filter)
|
||||
{
|
||||
# Calling Log::delay() in a filter policy hook is an error.
|
||||
local token = Log::delay(id, rec);
|
||||
Log::delay_finish(id, rec, token);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue