Allow Print Statements to be redirected to a Log# This is a combination of 3 commits.

This commit is contained in:
Dev Bali 2019-11-06 19:07:07 -08:00
parent 75588956fc
commit c9016f1397
5 changed files with 89 additions and 0 deletions

View file

@ -75,6 +75,23 @@ export {
## Returns: The path to be used for the filter.
global default_path_func: function(id: ID, path: string, rec: any) : string &redef;
# Log Print Statements
type PrintLogInfo: record {
## Current timestamp.
ts: time &log;
## Set of strings passed to the print statement.
vals: set[string] &log;
};
redef enum Log::ID += {PRINTLOG};
## If true, logging is enabled for print statements instead of output to files
const print_to_log = F &redef;
## If print_to_log is true, this is the path to which the print Log Stream writes
const print_log_path = "print" &redef;
# Log rotation support.
## Information passed into rotation callback functions.
@ -643,3 +660,10 @@ function remove_default_filter(id: ID) : bool
{
return remove_filter(id, "default");
}
event zeek_init() &priority=5
{
if ( print_to_log )
# "print" added for the test coverage.find-bro-logs
Log::create_stream(PRINTLOG, [$columns=PrintLogInfo, $path=print_log_path]); #"print"
}