package
Write to a file until limits you define are reached, after which a new file is created to and written to until its limits are reached, and so on.
npm install rolling-fileGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Write to a file until limits you've defined are reached, after which a new file is created and written to until its limits are reached, and so on. Writing is done using write streams.
npm install rolling-filevar rollingFile = require('rolling-file');
var f = rollingFile('./logs', { fileName: 'foo', byteLimit: '500 MB' });
f.write('Hello, World!');
...
f.end();var rollingFile = require('rolling-file');
var f = rollingFile('./logs', { fileName: 'foo', interval: '1 day' });
f.write('Hello, World!');
...
f.end();var rollingFile = require('rolling-file');
var f = rollingFile('./logs', { fileName: 'foo', byteLimit: '500 MB', interval: '1 day' });
f.write('Hello, World!');
...
f.end();Parameters:
Returns: An object with properties for writing to the data stream:
The configuration parameter has the following options:
The naming of files is an automated process through which you have some control. You can provide a file name prefix and the file extension. A timestamp and an index are also added to the file name automatically.
The timestamp is formatted as YYYY-MM-DD-HHMMSS and it will contain the time stamp for when it was first written to if no interval is provided. If an interval is provided then the time stamp will reflect that time that lines up with that interval.
The index is added after the timestamp and is used to split multiple files that fit the same timestamp.
See below for some configurations and their potential output:
config = { fileName: 'foo', fileExtension: 'bar', byteLimit: '2 GB' };
possible_outputs = [
'foo.2000-01-01-102345.0.bar',
'foo.2000-01-01-102345.1.bar'
'foo.2000-01-01-180200.0.bar'
]config = { fileName: '', interval: '1 day', byteLimit: '500 MB' };
possible_outputs = [
'2000-01-01-000000.0.log',
'2000-01-01-000000.1.log',
'2000-01-02-000000.0.log',
'2000-01-03-000000.0.log'
];Estimated unpacked size across 5 packages.
4.4 MB
Includes dependencies.
3 direct dependencies.