diff --git a/README.md b/README.md index 784f094..175bfa6 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ const logger = new(winston.Logger)({ * __name__: Transport name * __level__: Level of messages this transport should log. (default: info) * __silent__: Boolean flag indicating whether to suppress output. (default: false) +* __autoReconnect__: Boolean flag indicating whether to reconnect on error. (default: false) * __graylogHost__: your server address (default: localhost) * __graylogPort__: your server port (default: 12201) * __graylogFlag__: Required on LDP Alpha diff --git a/lib/ovh-winston-ldp.js b/lib/ovh-winston-ldp.js index 2dfeafe..847c326 100644 --- a/lib/ovh-winston-ldp.js +++ b/lib/ovh-winston-ldp.js @@ -18,6 +18,7 @@ class OvhWinstonLDP extends winston.Transport { let extendedOptions = Object.assign({ level: "info", silent: false, + autoReconnect: false, graylogHost: "discover.logs.ovh.com", graylogPort: 12202, graylogHostname: OS.hostname(), @@ -65,6 +66,11 @@ class OvhWinstonLDP extends winston.Transport { this.client.on("error", (err) => { this.client.end(); console.log("[FATAL LOGGER]", err); + + if (this.autoReconnect) { + delete this.connecting; + this.client = null; + } }); return;