Entropic 2.11.1
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
83 bool initialize();
84
96 void record(const AuditEntry& entry);
97
103 void flush();
104
111 size_t entry_count() const;
112
119 std::filesystem::path log_path() const;
120
140 static int hook_callback(
141 entropic_hook_point_t hook_point,
142 const char* context_json,
143 char** modified_json,
144 void* user_data);
145
146private:
147 AuditLogConfig config_;
148 std::atomic<size_t> sequence_{0};
149 std::atomic<size_t> entry_count_{0};
150 std::mutex write_mutex_;
151 std::ofstream file_;
152 size_t buffered_count_ = 0;
153 size_t current_file_size_ = 0;
154
161 void write_line(const std::string& line);
162
169 static std::string utc_timestamp();
170
180 void rotate_if_needed();
181
187 void rotate_files();
188};
189
190} // 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:39
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:717