mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Add Log::rotation_format_func and Log::default_rotation_dir options
These may be redefined to customize log rotation path prefixes, including use of a directory. File extensions are still up to individual log writers to add themselves during the actual rotation. These new also allow for some simplication to the default ASCII postprocessor function: it eliminates the need for it doing an extra/awkward rename() operation that only changes the timestamp format. This also teaches the supervisor framework to use these new options to rotate ascii logs into a log-queue/ directory with a specific file name format (intended for an external archiver process to monitor separately).
This commit is contained in:
parent
6e67a40d24
commit
a06ef66edc
21 changed files with 510 additions and 118 deletions
|
@ -4,7 +4,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <ctime>
|
||||
#include <string_view>
|
||||
|
||||
#include "../Val.h"
|
||||
|
@ -30,18 +29,6 @@ class RotationFinishedMessage;
|
|||
class Manager : public plugin::ComponentManager<Tag, Component> {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Returns a formatted string representing the given time. This
|
||||
* string is used in the log file rotation process.
|
||||
*/
|
||||
static std::string FormatRotationTime(time_t t);
|
||||
|
||||
/**
|
||||
* Returns a formatted string representing the file rotation path. This
|
||||
* string is used in the log file rotation process.
|
||||
*/
|
||||
static std::string FormatRotationPath(std::string_view path, time_t t);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
|
@ -52,6 +39,24 @@ public:
|
|||
*/
|
||||
~Manager();
|
||||
|
||||
/**
|
||||
* Called after scripts are parsed; obtains values of customizable options.
|
||||
*/
|
||||
void InitPostScript();
|
||||
|
||||
/**
|
||||
* Calls the Log::rotation_format_func script function, tries to create
|
||||
* any directories (failure to falls back to using working dir for
|
||||
* rotation) and returns the formatted rotation path string that
|
||||
* will be sent along to writer threads to perform the actual rotation.
|
||||
* @param rotation_info The fields of a Log::RotationFmtInfo record
|
||||
* to create and pass to Log::rotation_format_func.
|
||||
*/
|
||||
std::string FormatRotationPath(zeek::EnumValPtr writer,
|
||||
std::string_view path, double open,
|
||||
double close, bool terminating,
|
||||
zeek::FuncPtr postprocesor);
|
||||
|
||||
/**
|
||||
* Creates a new log stream.
|
||||
*
|
||||
|
@ -290,6 +295,7 @@ private:
|
|||
|
||||
std::vector<Stream *> streams; // Indexed by stream enum.
|
||||
int rotations_pending; // Number of rotations not yet finished.
|
||||
zeek::FuncPtr rotation_format_func;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue