UNPKG

2.85 kBTypeScriptView Raw
1/// <reference types="node" />
2import { Writable } from "stream";
3export declare type Compressor = (source: string, dest: string) => string;
4export declare type Generator = (time: number | Date, index?: number) => string;
5export interface Options {
6 compress?: boolean | string | Compressor;
7 encoding?: BufferEncoding;
8 history?: string;
9 immutable?: boolean;
10 initialRotation?: boolean;
11 interval?: string;
12 intervalBoundary?: boolean;
13 maxFiles?: number;
14 maxSize?: string;
15 mode?: number;
16 path?: string;
17 rotate?: number;
18 size?: string;
19 teeToStdout?: boolean;
20}
21interface Opts {
22 compress?: string | Compressor;
23 encoding?: BufferEncoding;
24 history?: string;
25 immutable?: boolean;
26 initialRotation?: boolean;
27 interval?: {
28 num: number;
29 unit: string;
30 };
31 intervalBoundary?: boolean;
32 maxFiles?: number;
33 maxSize?: number;
34 mode?: number;
35 path?: string;
36 rotate?: number;
37 size?: number;
38 teeToStdout?: boolean;
39}
40declare type Callback = (error?: Error) => void;
41interface Chunk {
42 chunk: Buffer;
43 encoding: BufferEncoding;
44}
45export declare class RotatingFileStream extends Writable {
46 private createGzip;
47 private destroyer;
48 private error;
49 private exec;
50 private filename;
51 private finished;
52 private fsClose;
53 private fsCreateReadStream;
54 private fsCreateWriteStream;
55 private fsMkdir;
56 private fsOpen;
57 private fsReadFile;
58 private fsRename;
59 private fsStat;
60 private fsUnlink;
61 private fsWrite;
62 private fsWriteFile;
63 private generator;
64 private last;
65 private maxTimeout;
66 private next;
67 private opened;
68 private options;
69 private prev;
70 private rotatedName;
71 private rotation;
72 private size;
73 private stream;
74 private timer;
75 constructor(generator: Generator, options: Opts);
76 _destroy(error: Error, callback: Callback): void;
77 _final(callback: Callback): void;
78 _write(chunk: Buffer, encoding: BufferEncoding, callback: Callback): void;
79 _writev(chunks: Chunk[], callback: Callback): void;
80 private rewrite;
81 private writeToStdOut;
82 private init;
83 private makePath;
84 private reopen;
85 private reclose;
86 private now;
87 private rotate;
88 private findName;
89 private move;
90 private touch;
91 private classical;
92 private clear;
93 private intervalBoundsBig;
94 private intervalBounds;
95 private interval;
96 private compress;
97 private external;
98 private gzip;
99 private rotated;
100 private history;
101 private historyGather;
102 private historyRemove;
103 private historyCheckFiles;
104 private historyCheckSize;
105 private historyWrite;
106 private immutate;
107}
108export declare function createStream(filename: string | Generator, options?: Options): RotatingFileStream;
109export {};