-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
30 lines (22 loc) · 827 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"use strict";
import { createStream, Generator, Options, RotatingFileStream } from "rotating-file-stream";
import TransportStream from "winston-transport";
export interface WinstonRotatingFileOptions extends TransportStream.TransportStreamOptions {
filename: string | Generator;
rfsOptions?: Options;
}
// eslint-disable-next-line @typescript-eslint/no-var-requires
const message = require("triple-beam").MESSAGE;
export class WinstonRotatingFile extends TransportStream {
public stream: RotatingFileStream;
public constructor(options: WinstonRotatingFileOptions) {
super(options);
this.stream = createStream(options.filename, options.rfsOptions);
}
public close(): void {
this.stream.end();
}
public log(info: any, done: () => void): any {
this.stream.write(info[message], done);
}
}