-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathDateRollingFileStream.js
More file actions
41 lines (37 loc) · 1.15 KB
/
DateRollingFileStream.js
File metadata and controls
41 lines (37 loc) · 1.15 KB
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
const RollingFileWriteStream = require('./RollingFileWriteStream');
// just to adapt the previous version
class DateRollingFileStream extends RollingFileWriteStream {
constructor(filename, pattern, options) {
if (pattern && typeof(pattern) === 'object') {
options = pattern;
pattern = null;
}
if (!options) {
options = {};
}
if (!pattern) {
pattern = 'yyyy-MM-dd';
}
options.pattern = pattern;
if (!options.numBackups && options.numBackups !== 0) {
if (!options.daysToKeep && options.daysToKeep !== 0) {
options.daysToKeep = 1;
} else {
process.emitWarning(
"options.daysToKeep is deprecated due to the confusion it causes when used " +
"together with file size rolling. Please use options.numBackups instead.",
"DeprecationWarning", "streamroller-DEP0001"
);
}
options.numBackups = options.daysToKeep;
} else {
options.daysToKeep = options.numBackups;
}
super(filename, options);
this.mode = this.options.mode;
}
get theStream() {
return this.currentFileStream;
}
}
module.exports = DateRollingFileStream;