Question - Current active file is not recreated after being deleted by a worker.
See original GitHub issueI have this current setup for rotating-file-stream
writing logs whenever a request comes in.
rotating-file-stream
: 1.3.9
, 1.4.1
node
: v6.9.0, v10.4.0 (same as my windows)
OS
: Ubuntu 16.04
let filenameBase = 'some base file name'
let directory = 'directory'
function makeGenerator (lastIndex) {
let logIndex = 0
if (Util.isNumber(lastIndex)) {
logIndex = lastIndex
}
return function generator (time, index) {
logIndex++
return _filenameBase + '-' + logIndex + '.log'
}
}
let stream = rfs(makeGenerator(lastIndex), {
size: '1M',
interval: '1d',
immutable: true,
path: directory,
mode: 0o777
})
It works currently but if I remove the current active file filenameBase-logIndex.log
, the log being written are not flushed out to the file (expecting it to be recreated - which is currently working in windows) and only creates a new file when it has rotated (the size being recorded maxes out or reaches the maxSize threshold).
Not receiving any errors/warnings during the process.
I don’t know if this is the current behavior but please advise.
Edit: Tried to create a PoC for the fs.createWriteStream
writing entries and removing the file halfway does not throw any error on the stream and just keeps writing until stream.end()
is called.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Hi @homiedopie ,
I prefer following a different road; there are currently three open issues on rotating-file-stream: this one, #36 and #37, and the other two are about problems on windows and macOS; I prefer to not add something else working only under linux.
I hope you can understand, iCC
Hi @homiedopie ,
actually a good log file writing tool should, for each line (or lines block) it receive to write, to open in append the logfile, to write the line (or lines block) and to close the logfile.
This is something which rotating-file-stream doesn’t do and will solve many other problems more the one reported.
I’ve just decided to change rotating-file-stream behavior to do this in order to make it something more close to a good log file writing tool, but it will require some time.
Thank you for made me open my eyes! iCC