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