|
Entropic 2.3.8
Local-first agentic inference engine
|
JSONL audit logger for MCP tool calls. More...
#include <entropic/storage/audit_logger.h>
Public Member Functions | |
| AuditLogger (const AuditLogConfig &config) | |
| Construct with configuration. | |
| ~AuditLogger () | |
| Destructor — flushes and closes the log file. | |
| AuditLogger (const AuditLogger &)=delete | |
| AuditLogger & | operator= (const AuditLogger &)=delete |
| bool | initialize () |
| Open the log file and prepare for writing. | |
| void | record (const AuditEntry &entry) |
| Record a tool call audit entry. | |
| void | flush () |
| Force flush buffered entries to disk. | |
| size_t | entry_count () const |
| Get the number of entries recorded this session. | |
| std::filesystem::path | log_path () const |
| Get the file path of the current audit log. | |
Static Public Member Functions | |
| 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. | |
JSONL audit logger for MCP tool calls.
Writes one JSON line per tool execution to audit.jsonl. Thread-safe via write_mutex_. Atomic sequence counter ensures total ordering even under concurrent writes.
Definition at line 53 of file audit_logger.h.
|
explicit |
Construct with configuration.
| config | Audit log configuration. |
Definition at line 27 of file audit_logger.cpp.
| entropic::AuditLogger::~AuditLogger | ( | ) |
Destructor — flushes and closes the log file.
Definition at line 34 of file audit_logger.cpp.
| size_t entropic::AuditLogger::entry_count | ( | ) | const |
Get the number of entries recorded this session.
Definition at line 128 of file audit_logger.cpp.
| void entropic::AuditLogger::flush | ( | ) |
|
static |
Hook callback for POST_TOOL_CALL integration.
Static callback registered with HookRegistry. Extracts fields from the hook context JSON and AuditHookContext (user_data), constructs an AuditEntry, and calls record().
Never modifies or cancels — sets *modified_json = NULL and returns 0.
| hook_point | Hook point (expected: ENTROPIC_HOOK_POST_TOOL_CALL). | |
| context_json | JSON with tool_name, args, result, elapsed_ms. | |
| [out] | modified_json | Always set to NULL (no transformation). |
| user_data | Pointer to AuditHookContext. |
| hook_point | Hook point. | |
| context_json | JSON with tool execution details. | |
| [out] | modified_json | Always NULL. |
| user_data | Pointer to AuditHookContext. |
Definition at line 210 of file audit_logger.cpp.
| bool entropic::AuditLogger::initialize | ( | ) |
Open the log file and prepare for writing.
Opens audit.jsonl in the configured log_dir. If the file exists, new entries are APPENDED (not overwritten). The sequence counter starts at 0 for each new logger instance (it is monotonic per-session, not per-file).
Definition at line 48 of file audit_logger.cpp.
| std::filesystem::path entropic::AuditLogger::log_path | ( | ) | const |
Get the file path of the current audit log.
Definition at line 138 of file audit_logger.cpp.
| void entropic::AuditLogger::record | ( | const AuditEntry & | entry | ) |
Record a tool call audit entry.
Serializes the entry to JSON, adds session-level metadata (version, timestamp, session_id, sequence), and appends one line to the file. Thread-safe.
| entry | The audit log entry to write. |
| entry | The audit log entry to write. |
Definition at line 72 of file audit_logger.cpp.