-
Notifications
You must be signed in to change notification settings - Fork 36
Description
I have noticed that if I write something to the log, and then immediately do a process.exit();, then the line that was just logged will not be written.
I tried to close the writer first, using this function:
simple-node-logger/lib/FileAppender.js
Line 73 in 98b79f0
| this.closeWriter = function() { |
This function calls the end function on the stream. The end function is here:
https://nodejs.org/api/stream.html#stream_writable_end_chunk_encoding_callback
However, the end function is asynchronous which is why the data doesn't have time to be written. If it do a setTimeout and do the process.exit(); aftr some time (100ms) it works. But the isn't avery clean solution.
I would suggest to add a callback parameter to the closeWriter function that gets called when the stream is closed. If I would create a PR with such a function, would it be well received?