mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00
Preparing LogWriter API for rotation and flushing.
This commit is contained in:
parent
b98d5adcd5
commit
091547de4f
3 changed files with 47 additions and 3 deletions
|
@ -50,6 +50,37 @@ protected:
|
||||||
// should be reported via Error().
|
// should be reported via Error().
|
||||||
virtual bool DoWrite(int num_fields, LogField** fields, LogVal** vals) = 0;
|
virtual bool DoWrite(int num_fields, LogField** fields, LogVal** vals) = 0;
|
||||||
|
|
||||||
|
// Called when the flushing status for this writer is changed. If
|
||||||
|
// flushing is enabled, the writer should attempt to write out
|
||||||
|
// information as quickly as possible even if that may have an
|
||||||
|
// performance impact. If disabled (which the writer should assume to be
|
||||||
|
// the default), then it can buffer things up as necessary and write out
|
||||||
|
// in a way optimized for performance.
|
||||||
|
//
|
||||||
|
// A writer may ignore flushing if it doesn't fit with its semantics.
|
||||||
|
virtual void DoSetFlushing(bool enabled) = 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
|
||||||
|
//
|
||||||
|
// The string "rotate_path" is interpreted in writer-specific way, yet
|
||||||
|
// should generally should have similar semantics that the "path" passed
|
||||||
|
// into DoInit(), except that now it reflects the name to where the
|
||||||
|
// rotated output is to be moved. After rotation, output should continue
|
||||||
|
// normally with the standard "path". As an example, for file-based
|
||||||
|
// output, the rotate_path may be the original filename with an embedded
|
||||||
|
// timestamp.
|
||||||
|
//
|
||||||
|
// The writer must return false if an error occured that prevent the
|
||||||
|
// writer for continuing operation; it will then be disabled. The error
|
||||||
|
// reason should be reported via Error(). If a recoverable error occurs,
|
||||||
|
// still call Error(), but return true.
|
||||||
|
//
|
||||||
|
// A writer may ignore rotation requests if it doesn't fit with its
|
||||||
|
// semantics. In that case, still return true.
|
||||||
|
virtual bool DoRotate(string rotated_path) = 0;
|
||||||
|
|
||||||
// Called once on termination. Not called when any of the other methods
|
// Called once on termination. Not called when any of the other methods
|
||||||
// has previously signaled an error, i.e., executing this method signals
|
// has previously signaled an error, i.e., executing this method signals
|
||||||
// a regular shutdown.
|
// a regular shutdown.
|
||||||
|
|
|
@ -127,3 +127,14 @@ bool LogWriterAscii::DoWrite(int num_fields, LogField** fields, LogVal** vals)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LogWriterAscii::DoRotate(string rotated_path)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LogWriterAscii::DoSetFlushing(bool enabled)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,11 @@ public:
|
||||||
static LogWriter* Instantiate() { return new LogWriterAscii; }
|
static LogWriter* Instantiate() { return new LogWriterAscii; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool DoInit(string path, int num_fields, LogField** fields);
|
virtual bool DoInit(string path, int num_fields, LogField** fields);
|
||||||
bool DoWrite(int num_fields, LogField** fields, LogVal** vals);
|
virtual bool DoWrite(int num_fields, LogField** fields, LogVal** vals);
|
||||||
void DoFinish();
|
virtual void DoSetFlushing(bool enabled);
|
||||||
|
virtual bool DoRotate(string rotated_path);
|
||||||
|
virtual void DoFinish();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FILE* file;
|
FILE* file;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue