-
Notifications
You must be signed in to change notification settings - Fork 117
Open
Description
Hello, I was working on making sure all the Logs from Winston were flushed before my app quit. When trying to check that all of the logs that had made it into Syslog were send I found a few issues, my first issue was with the inFlight variable not being updated on the two places the project uses this.socket.write, leading to a negative number of inFlight messages. The second issue I was having is that if I remove the transport from a logger, the socket becomes not writeable, and there is no check around this.socket.write, causing random unhandled exceptions.
Here are the changes that I made for the first issue, If the project is accepting PRS, I can go ahead and put these chagnes into one.
diff --git a/node_modules/winston-syslog/lib/winston-syslog.js b/node_modules/winston-syslog/lib/winston-syslog.js
index 5b1e9f0..4d98d0e 100644
--- a/node_modules/winston-syslog/lib/winston-syslog.js
+++ b/node_modules/winston-syslog/lib/winston-syslog.js
@@ -181,6 +181,7 @@ class Syslog extends Transport {
// metadata, `meta`, to the specified `level`.
//
log(info, callback) {
let level = info[LEVEL];
if (!~levels.indexOf(level)) {
return callback(
@@ -252,6 +253,7 @@ class Syslog extends Transport {
if (this.isDgram) {
sendDgram();
} else {
+ this.inFlight++;
this.socket.write(syslogMsg, 'utf8', onError);
}
@@ -389,6 +391,7 @@ class Syslog extends Transport {
// When the socket is ready, write the current queue
// to it.
//
+ this.inFlight++;
this.socket.write(this.queue.join(''), 'utf8', onError);
this.emit('logged');eric-gonzalez-tfs
Metadata
Metadata
Assignees
Labels
No labels