UNPKG

@dollhousemcp/mcp-server

Version:

DollhouseMCP - A Model Context Protocol (MCP) server that enables dynamic AI persona management from markdown files, allowing Claude and other compatible AI assistants to activate and switch between different behavioral personas.

71 lines 3 kB
/** * File-based log sink: writes buffered entries to date-rotated files on disk. * * Error reporting in this file intentionally uses `process.stderr.write` rather * than the application logger. Using the logger would create a circular * dependency (logger → sink → logger) and risk infinite loops or masking the * original error. `process.stderr.write` is the correct pattern for any code * inside the logging subsystem itself. */ import type { ILogSink, ILogFormatter, UnifiedLogEntry } from '../types.js'; export interface FileLogSinkOptions { logDir: string; formatter: ILogFormatter; maxFileSize: number; retentionDays: number; securityRetentionDays: number; maxDirSizeBytes: number; maxFilesPerCategory: number; } export declare class FileLogSink implements ILogSink { private readonly logDir; private readonly formatter; private readonly maxFileSize; private readonly retentionDays; private readonly securityRetentionDays; private readonly maxDirSizeBytes; private readonly maxFilesPerCategory; private readonly buffers; private readonly currentDates; private readonly sequenceCounters; private readonly fileSizes; private initialized; private cleanupTimer; constructor(options: FileLogSinkOptions); write(entry: UnifiedLogEntry): void; flush(): Promise<void>; close(): Promise<void>; cleanupExpiredFiles(): Promise<void>; startCleanupTimer(): void; private ensureLogDir; /** * Scan the log directory to find the highest existing sequence number for a * given category+date. Used on startup/day-transition to resume from the * correct file instead of always resetting to sequence 0. * * Performance: O(n) over files in the directory, but called at most once per * category per calendar day (on process start or UTC midnight rollover). For * deployments with very large log directories, keep DOLLHOUSE_LOG_MAX_FILES_PER_CATEGORY * set (default 100) so this scan stays fast. * * NOTE: no inter-process locking — if two instances share a log dir they may * both scan and pick the same max seq, then both write to the same file. Each * instance should use its own dedicated log directory. See the troubleshooting * guide ("Multiple server instances sharing a log directory") for details. */ private scanMaxSequence; private resolveFilePath; /** * Delete oldest files per category when the file count exceeds * `maxFilesPerCategory`. Sorting is date ASC, then seq ASC within * the same date, so the oldest files are removed first. */ private cleanupByFileCount; /** * Delete oldest log files (by mtime) when the total directory size exceeds * `maxDirSizeBytes`. Emits a stderr warning when a security log is deleted * so operators can investigate or increase the cap. */ private cleanupByDirSize; } //# sourceMappingURL=FileLogSink.d.ts.map