import { BasicLogConfigurations, LogContract, LogLevel, LogMessage, LoggingData } from "../types.mjs"; import { LogChannel } from "../log-channel.mjs"; //#region ../@warlock.js/logger/src/channels/file-log.d.ts type FileLogConfig = BasicLogConfigurations & { storagePath?: string; /** * File name, without extension */ name?: string; /** * chunk mode * If set to `single`, the logs will be created in a single file, unless the rotate is set to true * If set to `daily`, the logs will be created in a daily file, unless the rotate is set to true * If set to `hourly`, the logs will be created in an hourly file, unless the rotate is set to true * @default single */ chunk?: "single" | "daily" | "hourly"; /** * Whether to rotate the file * * @default true */ rotate?: boolean; /** * File Extension * * @default log */ extension?: string; /** * If rotate is set, the rotate name will be added to the file name suffixed with `-` * * @default DD-MM-YYYY */ rotateFileName?: string; /** * Max file size before rotating the file * * @default 10MB */ maxFileSize?: number; /** * Set the max messages that needs to be added before writing to the file * * @default 100 */ maxMessagesToWrite?: number; /** * Group logs by * Please note that the order matters here * For example, if you set `groupBy: ['level', 'module']`, the logs will be added in level name first, then by module * * @default none */ groupBy?: ("level" | "module" | "action")[]; /** * Define what levels should be logged * * @default all */ levels?: LogLevel[]; /** * Date and time format */ dateFormat?: { date?: string; time?: string; }; }; declare class FileLog extends LogChannel implements LogContract { /** * {@inheritdoc} */ name: string; /** * Messages buffer */ protected messages: LogMessage[]; /** * Grouped messages */ protected groupedMessages: Record; /** * Default channel configurations */ protected defaultConfigurations: FileLogConfig; /** * Last write time */ protected lastWriteTime: number; /** * A flag to determine if the file is being written */ protected isWriting: boolean; /** * Handle for the periodic flush interval. Stored so it can be cleared * in `dispose()` — long-lived processes that create channels dynamically * would otherwise leak one timer per channel. */ protected flushIntervalHandle?: NodeJS.Timeout; /** * Check file size for file rotation */ protected checkAndRotateFile(filePath?: any): Promise; /** * Rotate log file */ protected rotateLogFile(): Promise; /** * Flush messages * * Starts a periodic re-check so low-traffic channels don't sit on buffered * entries indefinitely. The handle is stored on the instance so `dispose()` * can stop it — without this, every channel leaks a timer for the lifetime * of the process. */ protected initMessageFlush(): void; /** * Stop the background flush interval and drain any buffered entries. * * Call this when discarding a channel (e.g. reconfiguring the logger at * runtime) so the 5-second timer doesn't keep the event loop alive. Safe to * call more than once. */ dispose(): void; /** * Get file path */ get filePath(): any; /** * Get max messages */ protected get maxMessagesToWrite(): number; /** * Get file name */ get fileName(): string; /** * Get file extension */ get extension(): string; /** * Get content */ protected get content(): string; /** * Get storage path */ get storagePath(): string; /** * {@inheritdoc} */ protected init(): Promise; /** * Synchronously flush messages */ flushSync(): void; /** * Asynchronously drain buffered entries to disk. * * The async analogue of {@link flushSync}: it reuses the same async writer * as the background interval, so a caller on a graceful-shutdown path can * `await channel.flush()` (or `await log.flush()`) and rely on the buffer * being on disk once it resolves. `JSONFileLog` inherits this unchanged — * its overridden `writeMessagesToFile` performs the JSON merge. */ flush(): Promise; /** * {@inheritdoc} */ log(data: LoggingData): Promise; /** * Check if messages should be written */ protected checkIfMessagesShouldBeWritten(): Promise; /** * Should be called after messages are saved */ protected onSave(): void; /** * Check if messages should be grouped */ protected get messagedShouldBeGrouped(): boolean; /** * Write messages to the file */ protected writeMessagesToFile(): Promise; /** * Write grouped messages to the file */ protected writeGroupedMessagesToFile(): Promise; /** * Prepare grouped messages */ protected prepareGroupedMessages(): void; /** * Start writing to the file */ protected write(filePath: string, content: string): Promise; } //#endregion export { FileLog, FileLogConfig }; //# sourceMappingURL=file-log.d.mts.map