pino-transport-rotating-file
Version:
Plugin for pino to transport logs to rotating files
35 lines (34 loc) • 1.34 kB
TypeScript
import { Transform } from 'node:stream';
import { type ZlibOptions } from 'node:zlib';
import { type OnUnknown } from 'pino-abstract-transport';
type StorageUnit = 'K' | 'M' | 'G' | 'T' | 'P' | 'E';
type TimeUnit = 's' | 'm' | 'h' | 'd' | 'w' | 'M' | 'y';
type Integer = `${0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}${number | ''}`;
type Size = `${Integer}${StorageUnit}`;
type Interval = `${Integer}${TimeUnit}`;
type TimestampFormat = 'iso' | 'unix' | 'utc' | 'rfc2822' | 'epoch';
export interface PinoTransportOptions {
dir: string;
filename: string;
enabled: boolean;
size: Size;
interval: Interval;
compress: boolean;
immutable: boolean;
retentionDays?: number;
compressionOptions?: ZlibOptions;
errorLogFile?: string;
timestampFormat?: TimestampFormat;
skipPretty?: boolean;
errorFlushIntervalMs?: number;
}
/**
* @function pinoTransportRotatingFile
* @description Creates a Pino transport for rotating log files.
*
* @param {Partial<PinoTransportOptions>} options - The options for the rotating log file transport.
*
* @returns {Promise<Transform & OnUnknown>} A promise that resolves to the transport instance.
*/
export declare function pinoTransportRotatingFile(options?: Partial<PinoTransportOptions>): Promise<Transform & OnUnknown>;
export default pinoTransportRotatingFile;