Entropic 2.3.8
Local-first agentic inference engine
Loading...
Searching...
No Matches
audit_logger.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
16#pragma once
17
21
22#include <atomic>
23#include <cstddef>
24#include <filesystem>
25#include <fstream>
26#include <mutex>
27#include <string>
28
29namespace entropic {
30
54public:
60 explicit AuditLogger(const AuditLogConfig& config);
61
67
68 AuditLogger(const AuditLogger&) = delete;
69 AuditLogger& operator=(const AuditLogger&) = delete;
70
82 bool initialize();
83
94 void record(const AuditEntry& entry);
95
100 void flush();
101
107 size_t entry_count() const;
108
114 std::filesystem::path log_path() const;
115
134 static int hook_callback(
135 entropic_hook_point_t hook_point,
136 const char* context_json,
137 char** modified_json,
138 void* user_data);
139
140private:
141 AuditLogConfig config_;
142 std::atomic<size_t> sequence_{0};
143 std::atomic<size_t> entry_count_{0};
144 std::mutex write_mutex_;
145 std::ofstream file_;
146 size_t buffered_count_ = 0;
147 size_t current_file_size_ = 0;
148
155 void write_line(const std::string& line);
156
163 static std::string utc_timestamp();
164
174 void rotate_if_needed();
175
181 void rotate_files();
182};
183
184} // namespace entropic
AuditEntry struct and JSON serialization for JSONL audit log.
JSONL audit logger for MCP tool calls.
static int hook_callback(entropic_hook_point_t hook_point, const char *context_json, char **modified_json, void *user_data)
Hook callback for POST_TOOL_CALL integration.
bool initialize()
Open the log file and prepare for writing.
void flush()
Force flush buffered entries to disk.
std::filesystem::path log_path() const
Get the file path of the current audit log.
void record(const AuditEntry &entry)
Record a tool call audit entry.
size_t entry_count() const
Get the number of entries recorded this session.
~AuditLogger()
Destructor — flushes and closes the log file.
Configuration structs with defaults.
Hook point enum and callback types for engine lifecycle hooks.
entropic_hook_point_t
Hook points in the engine lifecycle.
Definition hooks.h:34
Activate model on GPU (WARM → ACTIVE).
A single audit log entry for one MCP tool call.
Definition audit_entry.h:30
Audit log configuration within StorageConfig.
Definition config.h:483