Rotation support.

This follows rather closely how rotation currently works in
rotate-logs.bro. logging.bro now defines:

        # Default rotation interval; zero disables rotation.
        const default_rotation_interval = 0secs &redef;

        # Default naming suffix format.
        const default_rotation_date_format = "%y-%m-%d_%H.%M.%S" &redef;

        # Default postprocessor for writers outputting into files.
        const default_rotation_postprocessor = "" &redef;

        # Default function to construct the name of the rotated file.
        # The default implementation includes
        # default_rotation_date_format into the file name.
        global default_rotation_path_func: function(info: RotationInfo) : string &redef;

Writer support for rotation is optional, usually it will only make
sense for file-based writers.

TODO: Currently, there's no way to customize rotation on a per file
basis, there are only the global defaults as described above.
Individual customization is coming next.
This commit is contained in:
Robin Sommer 2011-03-06 19:28:48 -08:00
parent 90af0d06c3
commit d6cef16f77
16 changed files with 387 additions and 68 deletions

View file

@ -15,16 +15,16 @@ public:
static LogWriter* Instantiate() { return new LogWriterAscii; }
protected:
virtual bool DoInit(string path, int num_fields, LogField** fields);
virtual bool DoWrite(int num_fields, LogField** fields, LogVal** vals);
virtual bool DoInit(string path, int num_fields, const LogField* const * fields);
virtual bool DoWrite(int num_fields, const LogField* const * fields, LogVal** vals);
virtual bool DoSetBuf(bool enabled);
virtual bool DoRotate(string rotated_path);
virtual bool DoRotate(string rotated_path, string postprocessr, double open, double close, bool terminating);
virtual bool DoFlush();
virtual void DoFinish();
private:
FILE* file;
char* fname;
string fname;
};
#endif