rotating-file-stream
rotating-file-stream copied to clipboard
[bug] it does not create the file again when it's writing
I am wondering if it would be possible to recreate the file if for some reason was deleted by an external operation after you have created the stream, for example, if you run the following code, once created the directory and the file you delete manually the file leaving empty the directory, then in theory the stream should continue writing into the file which it means it should create the file again if it does not exist.
const path = require('path');
const { createStream } = require('rotating-file-stream');
const dir = 'test-logs';
const options = {
interval: '1m',
path: path.resolve(process.cwd(), dir),
immutable: true
};
const stream = createStream('test.log', options);
setTimeout(() => {}, 600000);
let count = 0;
function write() {
stream.write(`write ${++count}\n`);
setTimeout(write, Math.random() * 10).unref();
}
write();
Current Result: The file is not created again therefore nothing is recorded when stream.write is called.
Expected Result: It should create the file in case it does not exist if stream.write is being called