forked from winstonjs/winston-daily-rotate-file
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
120 lines (96 loc) · 4.28 KB
/
index.d.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import TransportStream = require("winston-transport");
// referenced from https://stackoverflow.com/questions/40510611/typescript-interface-require-one-of-two-properties-to-exist
type RequireOnlyOne<T, Keys extends keyof T = keyof T> =
Pick<T, Exclude<keyof T, Keys>>
& {
[K in Keys]-?:
Pick<T, K>
& Partial<Record<Exclude<Keys, K>, undefined>>
}[Keys];
// merging into winston.transports
declare module 'winston/lib/winston/transports' {
interface Transports {
DailyRotateFile: typeof DailyRotateFile;
DailyRotateFileTransportOptions: DailyRotateFile.DailyRotateFileTransportOptions;
}
}
declare namespace DailyRotateFile {
type DailyRotateFileTransportOptions = RequireOnlyOne<GeneralDailyRotateFileTransportOptions, 'filename' | 'stream'>;
interface GeneralDailyRotateFileTransportOptions extends TransportStream.TransportStreamOptions {
json?: boolean;
eol?: string;
/**
* A string representing the moment.js date format to be used for rotating. The meta characters used in this string will dictate the frequency of the file rotation. For example, if your datePattern is simply 'HH' you will end up with 24 log files that are picked up and appended to every day. (default 'YYYY-MM-DD')
*/
datePattern?: string;
/**
* A boolean to define whether or not to gzip archived log files. (default 'false')
*/
zippedArchive?: boolean;
/**
* Filename to be used to log to. This filename can include the %DATE% placeholder which will include the formatted datePattern at that point in the filename. (default: 'winston.log.%DATE%)
*/
filename?: string;
/**
* The directory name to save log files to. (default: '.')
*/
dirname?: string;
/**
* Write directly to a custom stream and bypass the rotation capabilities. (default: null)
*/
stream?: NodeJS.WritableStream;
/**
* Maximum size of the file after which it will rotate. This can be a number of bytes, or units of kb, mb, and gb. If using the units, add 'k', 'm', or 'g' as the suffix. The units need to directly follow the number. (default: null)
*/
maxSize?: string | number;
/**
* Maximum number of logs to keep. If not set, no logs will be removed. This can be a number of files or number of days. If using days, add 'd' as the suffix. (default: null)
*/
maxFiles?: string | number;
/**
* An object resembling https://nodejs.org/api/fs.html#fs_fs_createwritestream_path_options indicating additional options that should be passed to the file stream. (default: `{ flags: 'a' }`)
*/
options?: string | object;
/**
* A string representing the name of the audit file. (default: './hash-audit.json')
*/
auditFile?: string;
/**
* A string representing the frequency of rotation. (default: 'custom')
*/
frequency?: string;
/**
* A boolean whether or not to generate file name from "datePattern" in UTC format. (default: false)
*/
utc?: boolean;
/**
* A string representing an extension to be added to the filename, if not included in the filename property. (default: '')
*/
extension?: string;
/**
* Create a tailable symlink to the current active log file. (default: false)
*/
createSymlink?: boolean;
/**
* The name of the tailable symlink. (default: 'current.log')
*/
symlinkName?: string;
/**
* Watch the current file being written to and recreate it in case of accidental deletion. (default: FALSE)
*/
watchLog?: boolean;
handleRejections?: boolean;
/**
* Use specified hashing algorithm for audit. (default: 'sha256')
*/
auditHashType?: string;
}
}
declare class DailyRotateFile extends TransportStream {
filename: string;
dirname: string;
logStream: NodeJS.WritableStream;
options: DailyRotateFile.DailyRotateFileTransportOptions;
constructor(options?: DailyRotateFile.DailyRotateFileTransportOptions);
}
export = DailyRotateFile;