/** * postgres-mcp — Audit Logger * * Async-buffered JSONL writer for the audit trail. Appends one * JSON object per line to a configurable file path, or writes to * stderr for containerised deployments (`--audit-log stderr`). * * Non-throwing by design: audit failures log to stderr but never * propagate to tool callers. */ import type { AuditConfig, AuditEntry } from "./types.js"; export declare class AuditLogger { readonly config: AuditConfig; private buffer; private flushTimer; private activeFlush; private closed; private dirEnsured; private readonly stderrMode; constructor(config: AuditConfig); /** * Append an audit entry to the buffer. * Non-blocking — the entry is serialised and queued; the * actual file write happens on the next flush cycle. */ log(entry: AuditEntry): void; /** * Flush the buffer to disk. * Safe to call concurrently — serialises via `this.activeFlush` Promise. */ flush(): Promise; /** * Gracefully close the logger — flush remaining entries and stop the timer. */ close(): Promise; /** * Read the most recent audit entries from the log file. * Uses a streaming tail-read: only the last TAIL_READ_BYTES (64 KB) are * read from disk, preventing O(n) memory spikes for large audit logs. * Used by the `postgres://audit` resource. * * @param count Maximum number of entries to return (default 50) */ recent(count?: number): Promise; /** * Ensure the parent directory of the log file exists. */ private ensureDirectory; /** * Rotate the log file if it exceeds the configured size limit. * Keeps up to 5 rotated files (`.1` through `.5`); older data is discarded. * Rotation failure is non-fatal — audit must not block tool execution. */ private rotateIfNeeded; } //# sourceMappingURL=logger.d.ts.map