import type { TransportRecord, TransportOptions, IBufferedTransport, HookLogEntry } from '../types/index.js'; /** * Options for {@link FileTransport}. Uses `destination` as the file path in * Node and as a `localStorage` key in the browser (the path component is * sanitised to `[a-zA-Z0-9_-]`). * */ export interface FileTransportOptions extends TransportOptions { /** * Where to write. In Node this is a file path (resolved relative to * `process.cwd()` and sanitised against path traversal). In the browser * this is a localStorage key (sanitised to alphanumeric + `-_`). * @default 'app.log' (Node) | 'better-logger:default' (browser) */ destination?: string; /** * Optional hook fired when the transport cannot write (FS error, * quota exceeded, browser tab in private mode, ...). Receives a * synthetic {@link HookLogEntry}. */ onError?: (entry: HookLogEntry) => void | Promise; } /** * File-based transport. * * - In Node, writes batches via `fs.promises.appendFile` (non-blocking). * - In the browser, writes batches into `localStorage` (fallback no-op if * `localStorage` is unavailable — e.g. private mode, sandboxed iframes). * * Fixed in 5.1.0: * - BUG-N3: uses async `fs.promises.appendFile` instead of sync `appendFileSync`. * - BUG-N4: destination is sanitised to reject path traversal (`..`, `~`, abs paths). * - BUG-N5: dynamic `import('node:fs/promises')` instead of CJS `require('fs')`. * - BUG-N6: browser case uses `localStorage` with try/catch (was silent no-op). * */ export declare class FileTransport implements IBufferedTransport { readonly name = "file"; private buffer; private flushTimer?; private options; private closed; constructor(options?: FileTransportOptions); get bufferSize(): number; get maxBufferSize(): number; isReady(): boolean; write(record: TransportRecord): void; flush(): Promise; private flushNode; private flushBrowser; close(): Promise; private resolveNodeDestination; private resolveBrowserKey; private emitError; } //# sourceMappingURL=FileTransport.d.ts.map