Skip to main content

Audit Logger API

Query, verify, and export HMAC-signed audit logs.

Functions

readAuditLog

function readAuditLog(
logPath: string,
filters?: AuditLogFilters
): AuditEntry[]

Query audit log with filters (service, operation, action, agentId, ruleId, after, before, limit).

verifyLog

function verifyLog(logPath: string, secret: string): {
valid: boolean;
totalEntries: number;
invalidEntries: string[];
}

Verify all HMAC signatures in log file.

exportLog

function exportLog(
entries: AuditEntry[],
format: 'json' | 'csv' | 'ndjson'
): string

Export log entries to different formats.

rotateLogIfNeeded

function rotateLogIfNeeded(
logPath: string,
maxSizeBytes?: number,
maxEntries?: number
): boolean

Rotate log if size (default 10MB) or entry count (default 10,000) exceeded.

Source

Implementation: packages/core/src/logging/audit.ts