import { IInstanceCheck } from "@spinajs/di"; import { fs } from "@spinajs/fs"; import { IFileTargetOptions, Log, ILogEntry, LogTarget, BatchQueue } from "@spinajs/log-common"; import { LogArchiveService } from "../archive/LogArchiveService.js"; import { ILogArchiveContext } from "../archive/context.js"; /** * Writes log messages to a file through the @spinajs/fs abstraction. * * Messages are buffered in memory and flushed as a single batched append, * either when the buffer reaches `maxBufferSize` or on a periodic flush tick. * Rotation / archiving / retention is delegated to {@link LogArchiveService}. * * A single async write-lock ( a promise-chain mutex ) serializes every flush * and every rotation, so a rename can never race an in-flight append. * * PerInstanceCheck: multiple file targets can point at different files, but two * targets with the same name share one writer. */ export declare class FileTarget extends LogTarget implements IInstanceCheck { protected Log: Log; /** * fs provider holding the active log file. */ protected Fs: fs; /** * fs provider archives are moved to ( defaults to `Fs` ). */ protected ArchiveFs: fs; /** * Directory ( relative to ArchiveFs ) archives are stored in. */ protected ArchiveDir: string; protected ArchiveService: LogArchiveService; protected Context: ILogArchiveContext; /** * Buffered-batch queue owning accumulation, the flush tick and the hard queue * cap. It delegates the actual batched append to {@link append} via onFlush. */ protected Queue: BatchQueue; /** * Set true when the queue drops overflow, so the drop warning is emitted ONCE * per overflow episode and reset when a batch appends successfully. */ protected Overflowed: boolean; /** * Async initialization ( fs resolution + mkdir + archive start ). write() * and flush() await this so nothing touches the fs before it is ready. */ protected Ready: Promise; /** * Promise-chain mutex tail. Every critical section ( flush, rotation ) chains * onto this so they run strictly one at a time. */ protected WriteLock: Promise; protected Disposed: boolean; __checkInstance__(creationOptions: IFileTargetOptions[]): boolean; resolve(): void; /** * Resolves fs providers, ensures directories exist, builds the archive * context and starts the archive service. */ protected init(): Promise; write(data: ILogEntry): Promise; /** * Builds the single line appended for one entry. Overridable so subclasses can * change ONLY the per-entry serialization while reusing the whole FileTarget * pipeline ( batched append, write-lock, rotation, retention, zip ). The base * renders the configured string `layout`. */ protected formatEntry(data: ILogEntry): string; /** * Flushes any buffered messages. Delegates to the queue's forceFlush so a * caller ( eg. dispose or a test ) can await the drain. */ protected flush(): Promise; forceFlush(): Promise; /** * Appends one batch as a single write, guarded by the write-lock ( the SAME * lock rotation uses, so a rename can never race an append ). On failure the * batch is requeued at the FRONT so nothing is lost ( never-drop, bounded by * maxQueue ). This ALWAYS resolves ( never rejects ) so queue.shutdown() - * driven by dispose() - never rejects. */ protected append(batch: string[]): Promise; dispose(): Promise; /** * Runs `fn` under the shared write-lock. Flush and rotation both go through * here, so a rename can never overlap an append. */ protected withWriteLock(fn: () => Promise): Promise; /** * Active log path relative to the fs provider base path. Recomputed each call * so dynamic ( eg. date-based ) paths work. */ protected activePath(): string; /** * Normalizes a configured path to forward slashes and strips a leading * separator. Paths are interpreted relative to the fs provider base path - * the provider itself sandboxes and resolves them, so we only canonicalize * separators here. */ protected normalize(p: string): string; } //# sourceMappingURL=FileTarget.d.ts.map