Skip to content

Commit

Permalink
Merge pull request #2 from fdelayen/master
Browse files Browse the repository at this point in the history
feat(autoReconnect) Add autoReconnect option to reconnect on error
  • Loading branch information
Kévin Bonduelle authored Sep 20, 2017
2 parents 3963fe8 + fd0a408 commit c0c3bf4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions lib/ovh-winston-ldp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c0c3bf4

Please sign in to comment.