Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ logger.info('end of log message');
logger.end();
```

The transport constructor accepts the same options as `createFluentSender`, including `enableReconnect`.

**NOTE** If you use `winston@2`, you can use `fluent-logger@2.7.0` or earlier. If you use `winston@3`, you can use `fluent-logger@2.8` or later.

### stream
Expand Down Expand Up @@ -343,6 +345,11 @@ See [socket.setTimeout][2]
Set the reconnect interval in milliseconds.
If error occurs then reconnect after this interval.

**enableReconnect**

Enable automatic reconnect. Default is `true`.
Set this to `false` to disable automatic reconnect.

[1]: https://nodejs.org/api/net.html#net_socket_connect_path_connectlistener
[2]: https://nodejs.org/api/net.html#net_socket_settimeout_timeout_callback

Expand Down
1 change: 1 addition & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ declare namespace fluentLogger {
timeout?: number;
tls?: any;
tlsOptions?: any;
enableReconnect?: boolean;
reconnectInterval?: number;
requireAckResponse?: boolean;
ackResponseTimeout?: number;
Expand Down
20 changes: 20 additions & 0 deletions test/test.winston.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
/* globals describe, it */
/* eslint node/no-unpublished-require: ["error", {"allowModules": ["async", "chai", "winston"]}] */
const expect = require('chai').expect;
const fs = require('fs');
const path = require('path');
const winstonSupport = require('../lib/winston');
const winston = require('winston');
const runServer = require('../lib/testHelper').runServer;
Expand Down Expand Up @@ -41,5 +43,23 @@ describe('winston', () => {
}, 1000);
});
});

it('should honor enableReconnect', (done) => {
const transport = new winstonSupport('debug', {
enableReconnect: false,
reconnectInterval: 100
});
expect(transport.sender.enableReconnect).to.be.equal(false);
expect(transport.sender._eventEmitter.listeners('error').length).to.be.equal(0);
done();
});
});

describe('types', () => {
it('should include enableReconnect in Options', (done) => {
const dts = fs.readFileSync(path.join(__dirname, '../lib/index.d.ts'), 'utf8');
expect(dts).to.match(/interface Options \{[\s\S]*enableReconnect\?:\s*boolean/);
done();
});
});
});