RollingFileStream.js 605 B

123456789101112131415161718192021222324252627
  1. const RollingFileWriteStream = require('./RollingFileWriteStream');
  2. // just to adapt the previous version
  3. class RollingFileStream extends RollingFileWriteStream {
  4. constructor(filename, size, backups, options) {
  5. if (!options) {
  6. options = {};
  7. }
  8. if (size) {
  9. options.maxSize = size;
  10. }
  11. if (!backups) {
  12. backups = 1;
  13. }
  14. options.numToKeep = backups;
  15. super(filename, options);
  16. this.backups = this.options.numToKeep;
  17. this.size = this.options.maxSize;
  18. }
  19. get theStream() {
  20. return this.currentFileStream;
  21. }
  22. }
  23. module.exports = RollingFileStream;