Skip to content

Commit f3eb7e0

Browse files
committed
Updated README.md for clarity for <=2.2.4
1 parent 8cd42a0 commit f3eb7e0

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

README.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,25 @@ streamroller
33

44
node.js file streams that roll over when they reach a maximum size, or a date/time.
55

6-
npm install streamroller
6+
```sh
7+
npm install streamroller
8+
```
79

810
## usage
911

10-
var rollers = require('streamroller');
11-
var stream = new rollers.RollingFileStream('myfile', 1024, 3);
12-
stream.write("stuff");
13-
stream.end();
12+
```javascript
13+
var rollers = require('streamroller');
14+
var stream = new rollers.RollingFileStream('myfile', 1024, 3);
15+
stream.write("stuff");
16+
stream.end();
17+
```
1418

1519
The streams behave the same as standard node.js streams, except that when certain conditions are met they will rename the current file to a backup and start writing to a new file.
1620

1721
### new RollingFileStream(filename [, maxSize, numBackups, options])
1822
* `filename` (String)
1923
* `maxSize` - the size in bytes to trigger a rollover, if not provided this defaults to MAX_SAFE_INTEGER and the stream will not roll.
20-
* `numBackups` - the number of old files to keep
24+
* `numBackups` - the number of old files to keep (excluding the hot file)
2125
* `options` - Object
2226
* `encoding` - defaults to 'utf8'
2327
* `mode` - defaults to 0644
@@ -48,10 +52,10 @@ When filename size >= maxSize then:
4852
* `encoding` - defaults to 'utf8'
4953
* `mode` defaults to 0644
5054
* `flags` defaults to 'a' (see [fs.open](https://nodejs.org/dist/latest-v8.x/docs/api/fs.html#fs_fs_open_path_flags_mode_callback) for more details)
51-
* `compress` - (boolean) compress the backup files, defaults to false
55+
* `compress` - (boolean) defaults to `false` - compress the backup files using gzip (files will have `.gz` extension).
5256
* `keepFileExt` - (boolean) defaults to `false` - keep the file original extension. e.g.: `abc.log -> abc.2013-08-30.log`.
53-
* `alwaysIncludePattern` - (boolean) extend the initial file with the pattern, defaults to false
54-
* `daysToKeep` - (integer) if this is greater than 0, then files older than `daysToKeep` days will be deleted during file rolling.
57+
* `alwaysIncludePattern` - (boolean) extend the initial file with the pattern, defaults to `false`
58+
* `daysToKeep` - (integer) the number of old files that matches the pattern to keep (excluding the hot file)
5559

5660

5761
This returns a `WritableStream`. When the current time, formatted as `pattern`, changes then the current file will be renamed to `filename.formattedDate` where `formattedDate` is the result of processing the date through the pattern, and a new file will begin to be written. Streamroller uses [date-format](http://github.com/nomiddlename/date-format) to format dates, and the `pattern` should use the date-format format. e.g. with a `pattern` of `".yyyy-MM-dd"`, and assuming today is August 29, 2013 then writing to the stream today will just write to `filename`. At midnight (or more precisely, at the next file write after midnight), `filename` will be renamed to `filename.2013-08-29` and a new `filename` will be created. If `options.alwaysIncludePattern` is true, then the initial file will be `filename.2013-08-29` and no renaming will occur at midnight, but a new file will be written to with the name `filename.2013-08-30`.

0 commit comments

Comments
 (0)