Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
DEMO
Loading...
Searching...
No Matches
signet::forge::LogRetentionManager Class Reference

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< FileStatuslist_files (const std::string &log_dir, int64_t now_ns) const
 
const RetentionPolicypolicy () const noexcept
 Get the current retention policy.
 

Detailed Description

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.

Member Typedef Documentation

◆ ArchiveCallback

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.

◆ PreDeleteCallback

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.

Constructor & Destructor Documentation

◆ LogRetentionManager()

signet::forge::LogRetentionManager::LogRetentionManager ( RetentionPolicy  policy = {})
inlineexplicit

Definition at line 161 of file log_retention.hpp.

Member Function Documentation

◆ enforce()

RetentionSummary signet::forge::LogRetentionManager::enforce ( const std::string &  log_dir,
int64_t  now_ns 
) const
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.

Parameters
log_dirDirectory containing log files
now_nsCurrent time in nanoseconds since epoch
Returns
Summary of actions taken (or that would be taken in dry-run)

Definition at line 185 of file log_retention.hpp.

◆ list_files()

std::vector< FileStatus > signet::forge::LogRetentionManager::list_files ( const std::string &  log_dir,
int64_t  now_ns 
) const
inline

Definition at line 313 of file log_retention.hpp.

◆ policy()

const RetentionPolicy & signet::forge::LogRetentionManager::policy ( ) const
inlinenoexcept

Get the current retention policy.

Definition at line 363 of file log_retention.hpp.

◆ set_archive_callback()

void signet::forge::LogRetentionManager::set_archive_callback ( ArchiveCallback  cb)
inline

Set the archival callback.

Definition at line 167 of file log_retention.hpp.

◆ set_pre_delete_callback()

void signet::forge::LogRetentionManager::set_pre_delete_callback ( PreDeleteCallback  cb)
inline

Set the pre-deletion callback.

Definition at line 172 of file log_retention.hpp.


The documentation for this class was generated from the following file: