1 |
|
2 | import { Readable, Writable } from "stream";
|
3 | export declare class RotatingFileStreamError extends Error {
|
4 | code: string;
|
5 | constructor();
|
6 | }
|
7 | export declare type Compressor = (source: string, dest: string) => string;
|
8 | export declare type Generator = (time: number | Date, index?: number) => string;
|
9 | interface RotatingFileStreamEvents {
|
10 | close: () => void;
|
11 | drain: () => void;
|
12 | error: (err: Error) => void;
|
13 | finish: () => void;
|
14 | pipe: (src: Readable) => void;
|
15 | unpipe: (src: Readable) => void;
|
16 | external: (stdout: string, stderr: string) => void;
|
17 | history: () => void;
|
18 | open: (filename: string) => void;
|
19 | removed: (filename: string, number: boolean) => void;
|
20 | rotation: () => void;
|
21 | rotated: (filename: string) => void;
|
22 | warning: (error: Error) => void;
|
23 | }
|
24 | export declare interface RotatingFileStream extends Writable {
|
25 | addListener<Event extends keyof RotatingFileStreamEvents>(event: Event, listener: RotatingFileStreamEvents[Event]): this;
|
26 | emit<Event extends keyof RotatingFileStreamEvents>(event: Event, ...args: Parameters<RotatingFileStreamEvents[Event]>): boolean;
|
27 | on<Event extends keyof RotatingFileStreamEvents>(event: Event, listener: RotatingFileStreamEvents[Event]): this;
|
28 | once<Event extends keyof RotatingFileStreamEvents>(event: Event, listener: RotatingFileStreamEvents[Event]): this;
|
29 | prependListener<Event extends keyof RotatingFileStreamEvents>(event: Event, listener: RotatingFileStreamEvents[Event]): this;
|
30 | prependOnceListener<Event extends keyof RotatingFileStreamEvents>(event: Event, listener: RotatingFileStreamEvents[Event]): this;
|
31 | removeListener<Event extends keyof RotatingFileStreamEvents>(event: Event, listener: RotatingFileStreamEvents[Event]): this;
|
32 | }
|
33 | export interface Options {
|
34 | compress?: boolean | string | Compressor;
|
35 | encoding?: BufferEncoding;
|
36 | history?: string;
|
37 | immutable?: boolean;
|
38 | initialRotation?: boolean;
|
39 | interval?: string;
|
40 | intervalBoundary?: boolean;
|
41 | maxFiles?: number;
|
42 | maxSize?: string;
|
43 | mode?: number;
|
44 | omitExtension?: boolean;
|
45 | path?: string;
|
46 | rotate?: number;
|
47 | size?: string;
|
48 | teeToStdout?: boolean;
|
49 | }
|
50 | interface Opts {
|
51 | compress?: string | Compressor;
|
52 | encoding?: BufferEncoding;
|
53 | history?: string;
|
54 | immutable?: boolean;
|
55 | initialRotation?: boolean;
|
56 | interval?: {
|
57 | num: number;
|
58 | unit: string;
|
59 | };
|
60 | intervalBoundary?: boolean;
|
61 | maxFiles?: number;
|
62 | maxSize?: number;
|
63 | mode?: number;
|
64 | omitExtension?: boolean;
|
65 | path?: string;
|
66 | rotate?: number;
|
67 | size?: number;
|
68 | teeToStdout?: boolean;
|
69 | }
|
70 | declare type Callback = (error?: Error) => void;
|
71 | interface Chunk {
|
72 | chunk: Buffer;
|
73 | encoding: BufferEncoding;
|
74 | }
|
75 | export declare class RotatingFileStream extends Writable {
|
76 | private createGzip;
|
77 | private exec;
|
78 | private file;
|
79 | private filename;
|
80 | private finished;
|
81 | private fsCreateReadStream;
|
82 | private fsCreateWriteStream;
|
83 | private fsOpen;
|
84 | private fsReadFile;
|
85 | private fsStat;
|
86 | private generator;
|
87 | private initPromise;
|
88 | private last;
|
89 | private maxTimeout;
|
90 | private next;
|
91 | private options;
|
92 | private prev;
|
93 | private rotation;
|
94 | private size;
|
95 | private stdout;
|
96 | private timeout;
|
97 | private timeoutPromise;
|
98 | constructor(generator: Generator, options: Opts);
|
99 | _destroy(error: Error, callback: Callback): void;
|
100 | _final(callback: Callback): void;
|
101 | _write(chunk: Buffer, encoding: BufferEncoding, callback: Callback): void;
|
102 | _writev(chunks: Chunk[], callback: Callback): void;
|
103 | private refinal;
|
104 | private rewrite;
|
105 | private init;
|
106 | private makePath;
|
107 | private reopen;
|
108 | private reclose;
|
109 | private now;
|
110 | private rotate;
|
111 | private findName;
|
112 | private move;
|
113 | private touch;
|
114 | private classical;
|
115 | private clear;
|
116 | private intervalBoundsBig;
|
117 | private intervalBounds;
|
118 | private interval;
|
119 | private compress;
|
120 | private gzip;
|
121 | private rotated;
|
122 | private history;
|
123 | private immutate;
|
124 | }
|
125 | export declare function createStream(filename: string | Generator, options?: Options): RotatingFileStream;
|
126 | export {};
|