Working on the logging API exposed to scripts.

- Moving all functions into the Log::* namespace, using the recent
  bifcl updates. Moved logging-specific stuff to logging.bif.

- Log::create_stream() now takes a record Log::Stream as its second
  argument, which specifies columns and (optionally) the event.

- All the internal BiFs are now called "Log::__<something>", with
  script-level wrappers "Log::<something>". That first allows to add
  additional code at the script-level, and second makes things better
  comprehendible as now all relevant functionality is collected (and
  later documetned) in policy/logging.bro.

- New function Log::flush(id), which does the obvious assuming the
  writer supports it.

- add_default_filter() is now called implicitly with every
  create_stream(). Seems that we usually want that functionality, and
  when not, remove_default_filter() gets rid of it.

- The namespace of a stream's ID is now used as the default "path"
  (e.g., if the namespace is SSH, the default log file is "ssh.log").

- Updated policy/test-logging.bro as well as the btest tests according
  to these changes.
This commit is contained in:
Robin Sommer 2011-02-27 15:05:47 -08:00
parent e3b2748fa6
commit ab15437339
26 changed files with 337 additions and 451 deletions

View file

@ -31,9 +31,12 @@ public:
// occured, in which case the writer must not be used further.
bool Write(LogVal** vals);
// Sets the buffering status for the writer, if the writer supports
// Sets the buffering status for the writer, if the writer supports it.
bool SetBuf(bool enabled);
// Flushes any currently buffered output, if the writer support it.
bool Flush();
// Finished writing to this logger. Will not be called if an error has
// been indicated earlier. After calling this, no more writing must be
// performed.
@ -65,6 +68,12 @@ protected:
// semantics.
virtual bool DoSetBuf(bool enabled) = 0;
// Called to flush any currently buffered output.
//
// A writer may ignore flush requests if it doesn't fit with its
// semantics.
virtual bool DoFlush() = 0;
// Called when a log output is to be rotated. Most directly, this only
// applies to writers outputting files, thoug a writer may also trigger
// other regular actions if that fits a similar model