1234567891011121314151617181920212223242526272829303132333435363738394041 |
- 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 the confusion it causes when used " +
- "together with file size rolling. Please use options.numBackups instead.",
- "DeprecationWarning", "StreamRoller0001"
- );
- }
- 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;
|