Open KrysKruk opened 5 years ago
Could you show me your code?
The behavior that I expected:
// This will close the logger and its internal socket as soon as possible.
logger.end();
// This will close the logger and its internal socket after send the last message.
logger.end("end", "The last message");
Hi guys!
I was struggling some time on automatically closing the
fluent
socket when idling. I wanted to emit some logs and then let the process to exit. That never happened, because the internalfluent
socket was still open. I could just call theend()
function, but that was not an option for me.After studying Node.js socket documentation I found out that calling
socket.setTimeout
doesn't really close the connection, only emits atimeout
event which then needs to be handled by the developer.That was of course my lack of knowledge, but I'm thinking how
fluent-logger-node
could be improved here.What do you guys think of emitting the
timeout
event on theFluentSender
and let developer callend()
method later?The other option would be adding e.g.
autoClose
orcloseOnTimeout
boolean flags to theFluentSender
constructor.Also I figured that in
tls
mode, the giventimeout
is not set on thesocket
(even{ tlsOptions: { timeout: 3 } }
doesn't work).For now I use a workaround:
Thanks for feedback. Sorry if I misunderstood the problem and there is some other way to handle that.