Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow for zero backups and zero daysToKeep #74

Merged
merged 1 commit into from
Jan 12, 2022

Conversation

lamweili
Copy link
Contributor

@lamweili lamweili commented Jan 12, 2022

Fixes #59

Public APIs:

  • RollingFileStream
    backups excludes the hot file (original behavior retained)
    backups=0backups=1 (default)backups=2backups=3
    filename.log
    filename.log.1
     
     
    filename.log
    filename.log.1
     
     
    filename.log
    filename.log.1
    filename.log.2
     
    filename.log
    filename.log.1
    filename.log.2
    filename.log.3
  • DateRollingFileStream
    daysToKeep excludes the hot file (original behavior retained)
    daysToKeep=0 (default)daysToKeep=1 (default)daysToKeep=2daysToKeep=3
    filename.log
    filename.log.2022-01-11
    filename.log.2022-01-10
    filename.log.2022-01-09
    filename.log
    filename.log.2022-01-11
     
     
    filename.log
    filename.log.2022-01-11
    filename.log.2022-01-10
     
    filename.log
    filename.log.2022-01-11
    filename.log.2022-01-10
    filename.log.2022-01-09

Private APIs (only if used directly and not via public APIs):

  • RollingFileWriteStream
    numToKeep excludes includes the hot file (new behavior)
    numToKeep=0numToKeep=1numToKeep=2numToKeep=3
    throws Error()
     
     
     
    filename.log
    filename.log.1
     
     
    filename.log
    filename.log.1
    filename.log.2
     
    filename.log
    filename.log.1
    filename.log.2
    filename.log.3

Important
It is also to note the file does not roll within itself (truncate its older entry for newer entry).
It truncates all and appends only the new entry.

var rollers = require('streamroller');
var stream = new rollers.RollingFileStream('myfile', 6, 0);
stream.write("abc"); // add as first row
stream.write("def"); // add as second row
stream.write("ghi"); // truncate all and add as first row
stream.end();

Output:

myfile   - ghi

@lamweili lamweili added this to the 3.0.0 milestone Jan 12, 2022
@lamweili lamweili merged commit eb9839d into master Jan 12, 2022
@lamweili lamweili mentioned this pull request Jan 12, 2022
@lamweili lamweili deleted the fix-allow-zero-backups-and-zero-daysToKeep branch January 12, 2022 18:26
lamweili added a commit to log4js-node/log4js-node that referenced this pull request Jan 19, 2022
**Important**
It is also to note the the file does not roll within itself (truncate its older entry for newer entry).
It truncates all and appends only the new entry.

```javascript
var rollers = require('streamroller');
var stream = new rollers.RollingFileStream('myfile', 6, 0);
stream.write("abc"); // add as first row
stream.write("def"); // add as second row
stream.write("ghi"); // truncate all and add as first row
stream.end();
```

Output:
```
myfile   - ghi
```
lamweili added a commit to log4js-node/log4js-node that referenced this pull request Jan 19, 2022
**Important**
It is also to note the file does not roll within itself (truncate its older entry for newer entry).
It truncates all and appends only the new entry.

```javascript
var rollers = require('streamroller');
var stream = new rollers.RollingFileStream('myfile', 6, 0);
stream.write("abc"); // add as first row
stream.write("def"); // add as second row
stream.write("ghi"); // truncate all and add as first row
stream.end();
```

Output:
```
myfile   - ghi
```
lamweili added a commit to log4js-node/log4js-node that referenced this pull request Jan 19, 2022
This was referenced Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow zero backups
1 participant