![]() |
Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
|
DEMO |
Manages log file lifecycle: retention, archival, and deletion. More...
#include <log_retention.hpp>
Classes | |
| struct | FileStatus |
| List all managed log files in a directory with their age classification. More... | |
Public Types | |
| using | ArchiveCallback = std::function< bool(const std::string &source_path)> |
| Callback invoked to archive a file. | |
| using | PreDeleteCallback = std::function< bool(const std::string &path)> |
| Callback invoked before deleting a file. | |
Public Member Functions | |
| LogRetentionManager (RetentionPolicy policy={}) | |
| void | set_archive_callback (ArchiveCallback cb) |
| Set the archival callback. | |
| void | set_pre_delete_callback (PreDeleteCallback cb) |
| Set the pre-deletion callback. | |
| RetentionSummary | enforce (const std::string &log_dir, int64_t now_ns) const |
| Enforce retention policy on a log directory. | |
| std::vector< FileStatus > | list_files (const std::string &log_dir, int64_t now_ns) const |
| const RetentionPolicy & | policy () const noexcept |
| Get the current retention policy. | |
Manages log file lifecycle: retention, archival, and deletion.
EU AI Act Art.12(3): Minimum 6-month retention. MiFID II RTS 24 Art.4: 5-year retention for order records.
Usage: RetentionPolicy policy; policy.enable_archival = true; policy.enable_deletion = true;
LogRetentionManager mgr(policy); mgr.set_archive_callback([](const std::string& src) { // Move to cold storage (S3, GCS, etc.) return move_to_cold_storage(src); });
auto summary = mgr.enforce("/audit/decisions", now_ns);
Definition at line 150 of file log_retention.hpp.
| using signet::forge::LogRetentionManager::ArchiveCallback = std::function<bool(const std::string& source_path)> |
Callback invoked to archive a file.
Returns true on success. The callback receives the source file path and should move/copy the file to archival storage.
Definition at line 155 of file log_retention.hpp.
| using signet::forge::LogRetentionManager::PreDeleteCallback = std::function<bool(const std::string& path)> |
Callback invoked before deleting a file.
Returns true to allow deletion. Can be used for final backup or compliance logging.
Definition at line 159 of file log_retention.hpp.
|
inlineexplicit |
Definition at line 161 of file log_retention.hpp.
|
inline |
Enforce retention policy on a log directory.
Scans the directory for files matching the policy's file_suffix, determines their age from filesystem modification time, and applies archival/deletion rules.
| log_dir | Directory containing log files |
| now_ns | Current time in nanoseconds since epoch |
Definition at line 185 of file log_retention.hpp.
|
inline |
Definition at line 313 of file log_retention.hpp.
|
inlinenoexcept |
Get the current retention policy.
Definition at line 363 of file log_retention.hpp.
|
inline |
Set the archival callback.
Definition at line 167 of file log_retention.hpp.
|
inline |
Set the pre-deletion callback.
Definition at line 172 of file log_retention.hpp.