You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DateRollingFileStream inherit from RollingFileWriteStream which provide cleaning up mechanism based on numToKeep
classRollingFileWriteStreamextendsWritable{//...// Sorted from the oldest to the latestasync_getExistingFiles(){constfiles=awaitfs.readdir(this.fileObject.dir).catch(()=>[]);debug(`_getExistingFiles: files=${files}`);constexistingFileDetails=files.map(n=>this.fileNameParser(n)).filter(n=>n);constgetKey=n=>(n.timestamp ? n.timestamp : newNow().getTime())-n.index;existingFileDetails.sort((a,b)=>getKey(a)-getKey(b));returnexistingFileDetails;}//...async_clean(){constexistingFileDetails=awaitthis._getExistingFiles();debug(`_clean: numToKeep = ${this.options.numToKeep}, existingFiles = ${existingFileDetails.length}`);debug("_clean: existing files are: ",existingFileDetails);if(this._tooManyFiles(existingFileDetails.length)){constfileNamesToRemove=existingFileDetails.slice(0,existingFileDetails.length-this.options.numToKeep-1).map(f=>path.format({dir: this.fileObject.dir,base: f.filename}));awaitdeleteFiles(fileNamesToRemove);}}}
I think it's kind of confusing documentation... or if there's a plan that streamroller implement file rotation based on file modified time or datetime naming rule in the future?
Thank you. :D
It's renamed to numBackups instead for clarity while daysToKeep is still backward compatible.
Usage of daysToKeep will result in process.emitWarning of deprecation.
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");
Activity
orbulant commentedon Sep 30, 2021
I agree, "daysToKeep' should actually be renamed to "filesToKeep".
lamweili commentedon Jan 19, 2022
It's renamed to
numBackupsinstead for clarity whiledaysToKeepis still backward compatible.Usage of
daysToKeepwill result inprocess.emitWarningof deprecation.https://github.com/log4js-node/streamroller/blob/272e5e32e742021a4340ab147f7bea24c8924ddd/lib/DateRollingFileStream.js#L21-L25
非推奨になっていたため