Change path conflicts between log filters to be auto-corrected.

This change makes it so when differing logging filters on the same
stream attempt to write to the same writer/path combination, the path
of the filter doing the later write will be automatically adjusted so
that it does not conflict with the other.  The path is adjusted by
appending "-N", where N is the smallest integer greater or equal to 2
required to resolve the path name conflict.

Addresses #842.
This commit is contained in:
Jon Siwek 2012-07-26 16:55:49 -05:00
parent 8633d91c40
commit 63e8bf72ed
7 changed files with 124 additions and 26 deletions

View file

@ -1,6 +1,9 @@
# @TEST-EXEC: bro -C -r $TRACES/wikipedia.trace %INPUT
# @TEST-EXEC: btest-diff reporter.log
# @TEST-EXEC: btest-diff http.log
# @TEST-EXEC: btest-diff http-2.log
# @TEST-EXEC: btest-diff http-3.log
# @TEST-EXEC: btest-diff http-2-2.log
@load base/protocols/http
@ -8,7 +11,14 @@ event bro_init()
{
# Both the default filter for the http stream and this new one will
# attempt to have the same writer write to path "http", which will
# be reported as a warning and the write skipped.
# be reported as a warning and the path auto-corrected to "http-2"
local filter: Log::Filter = [$name="host-only", $include=set("host")];
# Same deal here, but should be auto-corrected to "http-3".
local filter2: Log::Filter = [$name="uri-only", $include=set("uri")];
# Conflict between auto-correct paths needs to be corrected, too, this
# time it will be "http-2-2".
local filter3: Log::Filter = [$path="http-2", $name="status-only", $include=set("status_code")];
Log::add_filter(HTTP::LOG, filter);
Log::add_filter(HTTP::LOG, filter2);
Log::add_filter(HTTP::LOG, filter3);
}