mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 00:58: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
17
src/util.h
17
src/util.h
|
@ -193,9 +193,22 @@ extern FILE* rotate_file(const char* name, RecordVal* rotate_info);
|
|||
// This mimics the script-level function with the same name.
|
||||
const char* log_file_name(const char* tag);
|
||||
|
||||
// Parse a time string of the form "HH:MM" (as used for the rotation base
|
||||
// time) into a double representing the number of seconds. Returns -1 if the
|
||||
// string cannot be parsed. The function's result is intended to be used with
|
||||
// calc_next_rotate().
|
||||
//
|
||||
// This function is not thread-safe.
|
||||
double parse_rotate_base_time(const char* rotate_base_time);
|
||||
|
||||
// Calculate the duration until the next time a file is to be rotated, based
|
||||
// on the given rotate_interval and rotate_base_time.
|
||||
double calc_next_rotate(double rotate_interval, const char* rotate_base_time);
|
||||
// on the given rotate_interval and rotate_base_time. 'current' the the
|
||||
// current time to be used as base, 'rotate_interval' the rotation interval,
|
||||
// and 'base' the value returned by parse_rotate_base_time(). For the latter,
|
||||
// if the function returned -1, that's fine, calc_next_rotate() handles that.
|
||||
//
|
||||
// This function is thread-safe.
|
||||
double calc_next_rotate(double current, double rotate_interval, double base);
|
||||
|
||||
// Terminates processing gracefully, similar to pressing CTRL-C.
|
||||
void terminate_processing();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue