Socket
Socket
Sign inDemoInstall

fluent-logger

Package Overview
Dependencies
Maintainers
4
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fluent-logger - npm Package Compare versions

Comparing version 2.6.1 to 2.6.2

.eslintrc.js

4

lib/event-time.js

@@ -37,3 +37,3 @@ 'use strict';

module.exports = exports = {};
exports.EventTime = EventTime;
module.exports = {};
module.exports.EventTime = EventTime;

@@ -8,3 +8,3 @@ 'use strict';

module.exports = {
configure: function(config){
configure: function(config) {
sender.end();

@@ -17,3 +17,3 @@ var tag = config;

createFluentSender: function(tag, options){
createFluentSender: function(tag, options) {
var _sender = new FluentSender(tag, options);

@@ -37,5 +37,5 @@ _sender._setupErrorHandler();

var methods = ['emit', 'end', 'addListener', 'on', 'once', 'removeListener', 'removeAllListeners', 'setMaxListeners', 'getMaxListeners'];
methods.forEach(function(attr, i){
module.exports[attr] = function(){
if( sender ){
methods.forEach((attr, i) => {
module.exports[attr] = function() {
if (sender) {
return sender[attr].apply(sender, Array.prototype.slice.call(arguments));

@@ -42,0 +42,0 @@ }

'use strict';
var util = require('util');
var EventEmitter = require('events').EventEmitter;

@@ -16,3 +15,3 @@ var msgpack = require('msgpack-lite');

function FluentSender(tag_prefix, options){
function FluentSender(tag_prefix, options) {
options = options || {};

@@ -59,3 +58,3 @@ this._eventMode = options.eventMode || 'Message'; // Message, PackedForward, CompressedPackedForward

FluentSender.prototype.emit = function(/*[label] <data>, [timestamp], [callback] */){
FluentSender.prototype.emit = function(/*[label] <data>, [timestamp], [callback] */) {
var label, data, timestamp, callback;

@@ -104,4 +103,4 @@ var args = Array.prototype.slice.call(arguments);

['addListener', 'on', 'once', 'removeListener', 'removeAllListeners', 'setMaxListeners', 'getMaxListeners'].forEach(function(attr, i){
FluentSender.prototype[attr] = function(){
['addListener', 'on', 'once', 'removeListener', 'removeAllListeners', 'setMaxListeners', 'getMaxListeners'].forEach((attr, i) => {
FluentSender.prototype[attr] = function() {
return this._eventEmitter[attr].apply(this._eventEmitter, Array.prototype.slice.call(arguments));

@@ -111,3 +110,3 @@ };

FluentSender.prototype.end = function(label, data, callback){
FluentSender.prototype.end = function(label, data, callback) {
if ((label != null && data != null)) {

@@ -150,3 +149,3 @@ this.emit(label, data, (err) => {

FluentSender.prototype._makePacketItem = function(tag, time, data){
FluentSender.prototype._makePacketItem = function(tag, time, data) {
if (typeof time !== 'number' && !(time instanceof EventTime)) {

@@ -202,3 +201,3 @@ time = Math.floor((time ? time.getTime() : Date.now()) / this._timeResolution);

FluentSender.prototype._connect = function(callback){
FluentSender.prototype._connect = function(callback) {
if (this._connecting) {

@@ -276,3 +275,3 @@ return;

if (!heloStatus.succeeded) {
this.internalLogger.error("Received invalid HELO message from " + this._socket.remoteAddress);
this.internalLogger.error('Received invalid HELO message from ' + this._socket.remoteAddress);
this._disconnect();

@@ -307,27 +306,32 @@ return;

process.nextTick(() => {
if (!this._socket) {
this._flushingSendQueue = false;
return;
}
this._waitToWrite();
});
};
if (this._socket.writable) {
if (this._eventMode === 'Message') {
FluentSender.prototype._waitToWrite = function() {
if (!this._socket) {
this._flushingSendQueue = false;
return;
}
if (this._socket.writable) {
if (this._eventMode === 'Message') {
this._doFlushSendQueue();
} else {
if (this._sendQueueSize >= this._sendQueueSizeLimit) {
this._flushSendQueueTimeoutId && clearTimeout(this._flushSendQueueTimeoutId);
this._doFlushSendQueue();
} else {
if (this._sendQueueSize >= this._sendQueueSizeLimit) {
this._flushSendQueueTimeoutId && clearTimeout(this._flushSendQueueTimeoutId);
this._flushSendQueueTimeoutId && clearTimeout(this._flushSendQueueTimeoutId);
this._flushSendQueueTimeoutId = setTimeout(() => {
this._doFlushSendQueue();
} else {
this._flushSendQueueTimeoutId && clearTimeout(this._flushSendQueueTimeoutId);
this._flushSendQueueTimeoutId = setTimeout(() => {
this._doFlushSendQueue();
}, this._flushInterval);
}
}, this._flushInterval);
}
} else {
process.nextTick(waitToWrite);
}
});
};
} else {
process.nextTick(() => {
this._waitToWrite();
});
}
}

@@ -374,4 +378,6 @@ FluentSender.prototype._doFlushSendQueue = function(timeoutId) {

if (response.ack !== options.chunk) {
var error = new FluentLoggerError.ResponseError('ack in response and chunk id in sent data are different',
{ ack: response.ack, chunk: options.chunk });
var error = new FluentLoggerError.ResponseError(
'ack in response and chunk id in sent data are different',
{ ack: response.ack, chunk: options.chunk }
);
callbacks.forEach((callback) => {

@@ -385,3 +391,3 @@ this._handleEvent('error', error, callback);

process.nextTick(() => {
this._doFlushSendQueue(); // if socket is still available
this._waitToWrite();
});

@@ -400,3 +406,3 @@ });

process.nextTick(() => {
this._doFlushSendQueue(); // if socket is still available
this._waitToWrite();
});

@@ -459,14 +465,14 @@ }

var sharedKeyHexdigest = crypto.createHash('sha512')
.update(this.sharedKeySalt)
.update(this.security.clientHostname)
.update(this.sharedKeyNonce)
.update(this.security.sharedKey)
.digest('hex');
.update(this.sharedKeySalt)
.update(this.security.clientHostname)
.update(this.sharedKeyNonce)
.update(this.security.sharedKey)
.digest('hex');
var ping = ['PING', this.security.clientHostname, this.sharedKeySalt, sharedKeyHexdigest];
if (Buffer.isBuffer(this.authentication) && Buffer.byteLength(this.authentication) !== 0) {
var passwordHexDigest = crypto.createHash('sha512')
.update(this.authentication)
.update(this.security.username || '')
.update(this.security.password || '')
.digest('hex');
.update(this.authentication)
.update(this.security.username || '')
.update(this.security.password || '')
.digest('hex');
ping.push(this.username, passwordHexDigest);

@@ -507,7 +513,7 @@ } else {

var clientsideHexdigest = crypto.createHash('sha512')
.update(this.sharedKeySalt)
.update(hostname)
.update(this.sharedKeyNonce)
.update(this.security.sharedKey)
.digest('hex');
.update(this.sharedKeySalt)
.update(hostname)
.update(this.sharedKeyNonce)
.update(this.security.sharedKey)
.digest('hex');
if (sharedKeyHexdigest !== clientsideHexdigest) {

@@ -556,3 +562,3 @@ return { succeeded: false, message: 'Sharedkey mismatch' };

module.exports = exports = {};
exports.FluentSender = FluentSender;
module.exports = {};
module.exports.FluentSender = FluentSender;
'use strict';
var net = require('net');
var fs = require('fs');
var msgpack = require('msgpack-lite');

@@ -17,6 +16,6 @@ var crypto = require('crypto');

this._server = net.createServer((socket) => {
var clientKey = socket.remoteAddress + ":" + socket.remotePort;
var clientKey = socket.remoteAddress + ':' + socket.remotePort;
this._clients[clientKey] = socket;
socket.on('end', () => {
delete(this._clients[clientKey]);
delete this._clients[clientKey];
});

@@ -29,3 +28,3 @@ var stream = msgpack.createDecodeStream();

if (authResult.succeeded) {
this._state= 'established';
this._state = 'established';
} else {

@@ -37,3 +36,2 @@ socket.end();

let options = null;
let records = null;
if (entries instanceof Buffer) {

@@ -46,3 +44,3 @@ options = m[2];

s.on('data', (data) => {
let time = data[0];
let _time = data[0];
let record = data[1];

@@ -100,5 +98,5 @@ this._received.push({

let options = {
"nonce": nonce,
"auth": this._options.security ? userAuthSalt : '',
"keepalive": false
'nonce': nonce,
'auth': this._options.security ? userAuthSalt : '',
'keepalive': false
};

@@ -124,10 +122,10 @@ return ['HELO', options];

let sharedKeyHexDigest = m[3];
let username = m[4];
let _username = m[4];
let passwordDigest = m[5];
let serverSideDigest = crypto.createHash('sha512')
.update(sharedKeySalt)
.update(hostname)
.update(this._nonce)
.update(this._options.security.sharedKey)
.digest('hex');
.update(sharedKeySalt)
.update(hostname)
.update(this._nonce)
.update(this._options.security.sharedKey)
.digest('hex');
if (sharedKeyHexDigest !== serverSideDigest) {

@@ -138,6 +136,6 @@ return { succeeded: false, reason: 'shared key mismatch' };

let serverSidePasswordDigest = crypto.createHash('sha512')
.update(this._userAuthSalt)
.update(this._options.security.username)
.update(this._options.security.password)
.digest('hex');
.update(this._userAuthSalt)
.update(this._options.security.username)
.update(this._options.security.password)
.digest('hex');
if (passwordDigest !== serverSidePasswordDigest) {

@@ -162,7 +160,7 @@ return { succeeded: false, reason: 'username/password mismatch' };

let sharedKeyDigestHex = crypto.createHash('sha512')
.update(authResult.sharedKeySalt)
.update(this._options.security.serverHostname)
.update(nonce)
.update(sharedKey)
.digest('hex');
.update(authResult.sharedKeySalt)
.update(this._options.security.serverHostname)
.update(nonce)
.update(sharedKey)
.digest('hex');
return ['PONG', true, '', this._options.security.serverHostname, sharedKeyDigestHex];

@@ -182,3 +180,3 @@ } else {

MockFluentdServer.prototype.close = function(callback) {
this._server.close(function() {
this._server.close(() => {
callback();

@@ -195,14 +193,14 @@ });

var server = new MockFluentdServer(options);
server.listen(function() {
callback(server, function(_callback) {
// wait 100 ms to receive all messages and then close
setTimeout(function() {
var messages = server.messages;
server.close(function() {
_callback && _callback(messages);
});
}, 100);
});
server.listen(() => {
callback(server, (_callback) => {
// wait 100 ms to receive all messages and then close
setTimeout(() => {
var messages = server.messages;
server.close(() => {
_callback && _callback(messages);
});
}, 100);
});
});
}
};

@@ -6,2 +6,3 @@ 'use strict';

/* eslint node/no-unpublished-require: ["error", {"allowModules": ["winston"]}] */
var sender = require('./sender');

@@ -17,3 +18,3 @@ var util = require('util');

} else {
if (typeof(tag) === 'object') {
if (typeof tag === 'object') {
options = tag;

@@ -56,2 +57,2 @@ tag = DEFAULT_TAG;

fluentTransport.prototype.name = 'fluent';
exports.Transport = fluentTransport;
module.exports.Transport = fluentTransport;
{
"name": "fluent-logger",
"version": "2.6.1",
"version": "2.6.2",
"main": "./lib/index.js",
"scripts": {
"test": "mocha -t 10000 --recursive"
"test": "mocha -t 10000 --recursive",
"lint": "eslint ."
},

@@ -39,3 +40,5 @@ "author": {

"mocha": "",
"winston": ""
"winston": "",
"eslint": "^4.11.0",
"eslint-plugin-node": ""
},

@@ -42,0 +45,0 @@ "license": "Apache-2.0",

@@ -131,6 +131,6 @@ # fluent-logger for Node.js

});
logger.on('error', function(error) {
logger.on('error', (error) => {
console.log(error);
});
logger.on('connect', function() {
logger.on('connect', () => {
console.log('connected!');

@@ -155,3 +155,4 @@ });

port: 24224,
timeout: 3.0
timeout: 3.0,
requireAckResponse: true // Add this option to wait response from Fluentd certainly
};

@@ -163,4 +164,11 @@ var fluentTransport = require('fluent-logger').support.winstonTransport();

logger.on('logging', (transport, level, message, meta) => {
if (meta.end && transport.sender && transport.sender.end) {
transport.sender.end();
}
});
logger.log('info', 'this log record is sent to fluent daemon');
logger.info('this log record is sent to fluent daemon');
logger.info('end of log message', { end: true });
```

@@ -173,2 +181,4 @@

```js
'use strict';
const Console = require('console').Console;
var sender = require('fluent-logger').createFluentSender('tag_prefix', {

@@ -182,2 +192,3 @@ host: 'localhost',

logger.log('this log record is sent to fluent daemon');
setTimeout(()=> sender.end(), 5000);
```

@@ -184,0 +195,0 @@

'use strict';
/* globals describe, it */
/* eslint node/no-unpublished-require: ["error", {"allowModules": ["chai"]}] */
var expect = require('chai').expect;

@@ -10,4 +12,4 @@ var EventTime = require('../lib/event-time').EventTime;

describe('EventTime', function() {
it('should equal to decoded value', function(done) {
describe('EventTime', () => {
it('should equal to decoded value', (done) => {
var eventTime = EventTime.now();

@@ -19,3 +21,3 @@ var encoded = msgpack.encode(eventTime, { codec: codec });

});
it('should equal fromDate and fromTimestamp', function(done) {
it('should equal fromDate and fromTimestamp', (done) => {
var now = new Date(1489543720999); // 2017-03-15T02:08:40.999Z

@@ -22,0 +24,0 @@ var timestamp = now.getTime();

'use strict';
/* globals describe, it */
/* eslint brace-style: ["error", "1tbs", {"allowSingleLine": true}] */
/* eslint no-unused-vars: ["error", {"args": "none"}] */
/* eslint node/no-unpublished-require: ["error", {"allowModules": ["async", "chai"]}] */
var expect = require('chai').expect;

@@ -15,6 +19,6 @@ var sender = require('../lib/sender');

describe("FluentSender", function(){
describe('FluentSender', () => {
it('should throw error', (done) => {
try {
let s = new sender.FluentSender('debug', { eventMode: 'Unknown' });
new sender.FluentSender('debug', { eventMode: 'Unknown' });
} catch (e) {

@@ -26,17 +30,17 @@ expect(e.message).to.be.equal('Unknown event mode: Unknown');

it('should send records', function(done){
runServer({}, function(server, finish){
it('should send records', (done) => {
runServer({}, (server, finish) => {
var s1 = new sender.FluentSender('debug', { port: server.port });
var emits = [];
function emit(k){
emits.push(function(done){ s1.emit('record', k, done); });
function emit(k) {
emits.push((done) => { s1.emit('record', k, done); });
}
for(var i=0; i<10; i++){
for (var i = 0; i < 10; i++) {
emit({ number: i });
}
emits.push(function(){
finish(function(data){
emits.push(() => {
finish((data) => {
expect(data.length).to.be.equal(10);
for(var i=0; i<10; i++){
expect(data[i].tag).to.be.equal("debug.record");
for (var i = 0; i < 10; i++) {
expect(data[i].tag).to.be.equal('debug.record');
expect(data[i].data.number).to.be.equal(i);

@@ -51,11 +55,11 @@ }

it('should emit connect event', function(done) {
runServer({}, function(server, finish) {
it('should emit connect event', (done) => {
runServer({}, (server, finish) => {
var s = new sender.FluentSender('debug', {port: server.port});
var called = false;
s.on('connect', function() {
s.on('connect', () => {
called = true;
});
s.emit({message: "1st message"}, function() {
finish(function(data) {
s.emit({message: '1st message'}, () => {
finish((data) => {
expect(called).to.equal(true);

@@ -68,3 +72,3 @@ done();

it('should raise error when connection fails', function(done){
it('should raise error when connection fails', (done) => {
var s = new sender.FluentSender('debug', {

@@ -74,3 +78,3 @@ host: 'localhost',

});
s.on('error', function(err){
s.on('error', (err) => {
expect(err.code).to.be.equal('ECONNREFUSED');

@@ -82,3 +86,3 @@ done();

it('should log error when connection fails w/ internal logger', function(done) {
it('should log error when connection fails w/ internal logger', (done) => {
var logger = {

@@ -113,9 +117,9 @@ buffer: {

it('should assure the sequence.', function(done){
runServer({}, function(server, finish){
it('should assure the sequence.', (done) => {
runServer({}, (server, finish) => {
var s = new sender.FluentSender('debug', {port: server.port});
s.emit('1st record', { message: '1st data' });
s.emit('2nd record', { message: '2nd data' });
s.end('last record', { message: 'last data' }, function(){
finish(function(data){
s.end('last record', { message: 'last data' }, () => {
finish((data) => {
expect(data[0].tag).to.be.equal('debug.1st record');

@@ -133,4 +137,4 @@ expect(data[0].data.message).to.be.equal('1st data');

it('should allow to emit with a custom timestamp', function(done){
runServer({}, function(server, finish){
it('should allow to emit with a custom timestamp', (done) => {
runServer({}, (server, finish) => {
var s = new sender.FluentSender('debug', {port: server.port});

@@ -140,4 +144,4 @@ var timestamp = new Date(2222, 12, 4);

s.emit("1st record", { message: "1st data" }, timestamp, function() {
finish(function(data) {
s.emit('1st record', { message: '1st data' }, timestamp, () => {
finish((data) => {
expect(data[0].time).to.be.equal(timestamp_seconds_since_epoch);

@@ -150,9 +154,9 @@ done();

it('should allow to emit with a custom numeric timestamp', function(done){
runServer({}, function(server, finish){
it('should allow to emit with a custom numeric timestamp', (done) => {
runServer({}, (server, finish) => {
var s = new sender.FluentSender('debug', {port: server.port});
var timestamp = Math.floor(new Date().getTime() / 1000);
s.emit("1st record", { message: "1st data" }, timestamp, function() {
finish(function(data) {
s.emit('1st record', { message: '1st data' }, timestamp, () => {
finish((data) => {
expect(data[0].time).to.be.equal(timestamp);

@@ -165,9 +169,9 @@ done();

it('should allow to emit with a EventTime', function(done) {
runServer({}, function(server, finish) {
it('should allow to emit with a EventTime', (done) => {
runServer({}, (server, finish) => {
var s = new sender.FluentSender('debug', {port: server.port});
var eventTime = EventTime.now();
s.emit('1st record', { message: '1st data' }, eventTime, function() {
finish(function(data) {
s.emit('1st record', { message: '1st data' }, eventTime, () => {
finish((data) => {
var decoded = EventTime.unpack(data[0].time.buffer);

@@ -181,12 +185,12 @@ expect(JSON.stringify(decoded)).to.equal(JSON.stringify(eventTime));

it('should resume the connection automatically and flush the queue', function(done){
it('should resume the connection automatically and flush the queue', (done) => {
var s = new sender.FluentSender('debug');
s.emit('1st record', { message: '1st data' });
s.on('error', function(err){
s.on('error', (err) => {
expect(err.code).to.be.equal('ECONNREFUSED');
runServer({}, function(server, finish){
runServer({}, (server, finish) => {
s.port = server.port;
s.emit('2nd record', { message: '2nd data' });
s.end('last record', { message: 'last data' }, function(){
finish(function(data){
s.end('last record', { message: 'last data' }, () => {
finish((data) => {
expect(data[0].tag).to.be.equal('debug.1st record');

@@ -205,15 +209,15 @@ expect(data[0].data.message).to.be.equal('1st data');

it('should reconnect when fluentd close the client socket suddenly', function(done){
runServer({}, function(server, finish){
it('should reconnect when fluentd close the client socket suddenly', (done) => {
runServer({}, (server, finish) => {
var s = new sender.FluentSender('debug', {port: server.port});
s.emit('foo', 'bar', function(){
s.emit('foo', 'bar', () => {
// connected
server.close(function(){
server.close(() => {
// waiting for the server closing all client socket.
(function waitForUnwritable(){
if( !(s._socket && s._socket.writable) ){
runServer({}, function(_server2, finish){
(function waitForUnwritable() {
if (!(s._socket && s._socket.writable)) {
runServer({}, (_server2, finish) => {
s.port = _server2.port; // in actuall case, s.port does not need to be updated.
s.emit('bar', { message: 'hoge' }, function(){
finish(function(data){
s.emit('bar', { message: 'hoge' }, () => {
finish((data) => {
expect(data[0].tag).to.be.equal('debug.bar');

@@ -225,4 +229,4 @@ expect(data[0].data.message).to.be.equal('hoge');

});
}else{
setTimeout(function(){
} else {
setTimeout(() => {
waitForUnwritable();

@@ -237,4 +241,4 @@ }, 100);

it('should send records with requireAckResponse', function(done) {
runServer({requireAckResponse: true}, function(server, finish) {
it('should send records with requireAckResponse', (done) => {
runServer({requireAckResponse: true}, (server, finish) => {
var s1 = new sender.FluentSender('debug', {

@@ -245,13 +249,13 @@ port: server.port,

var emits = [];
function emit(k){
emits.push(function(done){ s1.emit('record', k, done); });
function emit(k) {
emits.push((done) => { s1.emit('record', k, done); });
}
for (var i=0; i<10; i++) {
for (var i = 0; i < 10; i++) {
emit({ number: i });
}
emits.push(function(){
finish(function(data){
emits.push(() => {
finish((data) => {
expect(data.length).to.be.equal(10);
for(var i=0; i<10; i++){
expect(data[i].tag).to.be.equal("debug.record");
for (var i = 0; i < 10; i++) {
expect(data[i].tag).to.be.equal('debug.record');
expect(data[i].data.number).to.be.equal(i);

@@ -267,4 +271,4 @@ expect(data[i].options.chunk).to.be.equal(server.messages[i].options.chunk);

it('should send records ackResponseTimeout', function(done) {
runServer({requireAckResponse: false }, function(server, finish) {
it('should send records ackResponseTimeout', (done) => {
runServer({requireAckResponse: false }, (server, finish) => {
var s1 = new sender.FluentSender('debug', {

@@ -275,7 +279,7 @@ port: server.port,

});
s1.on('response-timeout', function(error) {
s1.on('response-timeout', (error) => {
expect(error).to.be.equal('ack response timeout');
});
s1.emit('record', { number: 1 });
finish(function(data) {
finish((data) => {
expect(data.length).to.be.equal(1);

@@ -287,3 +291,3 @@ done();

it('should set error handler', function(done){
it('should set error handler', (done) => {
var s = new sender.FluentSender('debug', {

@@ -358,3 +362,3 @@ reconnectInterval: 100

name: 'record and callback',
args: [{ bar: 1 }, function cb(){ cb.called = true; }],
args: [{ bar: 1 }, function cb() { cb.called = true; }],
expect: {

@@ -368,3 +372,3 @@ tag: 'debug',

name: 'record, time and callback',
args: [{ bar: 1 }, 12345, function cb(){ cb.called = true; }],
args: [{ bar: 1 }, 12345, function cb() { cb.called = true; }],
expect: {

@@ -386,9 +390,9 @@ tag: 'debug',

}
].forEach(function(testCase) {
it('should send records with '+testCase.name+' arguments', function(done){
runServer({}, function(server, finish){
].forEach((testCase) => {
it('should send records with ' + testCase.name + ' arguments', (done) => {
runServer({}, (server, finish) => {
var s1 = new sender.FluentSender('debug', { port: server.port });
s1.emit.apply(s1, testCase.args);
finish(function(data){
finish((data) => {
expect(data[0].tag).to.be.equal(testCase.expect.tag);

@@ -400,5 +404,5 @@ expect(data[0].data).to.be.deep.equal(testCase.expect.data);

testCase.args.forEach(function(arg) {
if (typeof arg === "function") {
expect(arg.called, "callback must be called").to.be.true;
testCase.args.forEach((arg) => {
if (typeof arg === 'function') {
expect(arg.called, 'callback must be called').to.be.true;
}

@@ -452,9 +456,9 @@ });

}
].forEach(function(testCase) {
it('should send records with '+testCase.name+' arguments without a default tag', function(done){
runServer({}, function(server, finish){
].forEach((testCase) => {
it('should send records with ' + testCase.name + ' arguments without a default tag', (done) => {
runServer({}, (server, finish) => {
var s1 = new sender.FluentSender(null, { port: server.port });
s1.emit.apply(s1, testCase.args);
finish(function(data){
finish((data) => {
expect(data[0].tag).to.be.equal(testCase.expect.tag);

@@ -466,5 +470,5 @@ expect(data[0].data).to.be.deep.equal(testCase.expect.data);

testCase.args.forEach(function(arg) {
if (typeof arg === "function") {
expect(arg.called, "callback must be called").to.be.true;
testCase.args.forEach((arg) => {
if (typeof arg === 'function') {
expect(arg.called, 'callback must be called').to.be.true;
}

@@ -493,3 +497,3 @@ });

name: 'record and callback',
args: [{ bar: 1 }, function cb(){ cb.called = true; }]
args: [{ bar: 1 }, function cb() { cb.called = true; }]
},

@@ -499,3 +503,3 @@

name: 'record, time and callback',
args: [{ bar: 1 }, 12345, function cb(){ cb.called = true; }]
args: [{ bar: 1 }, 12345, function cb() { cb.called = true; }]
},

@@ -507,7 +511,7 @@

}
].forEach(function(testCase) {
it('should not send records with '+testCase.name+' arguments without a default tag', function(done){
runServer({}, function(server, finish){
].forEach((testCase) => {
it('should not send records with ' + testCase.name + ' arguments without a default tag', (done) => {
runServer({}, (server, finish) => {
var s1 = new sender.FluentSender(null, { port: server.port });
s1.on('error', function(error) {
s1.on('error', (error) => {
expect(error.name).to.be.equal('MissingTagError');

@@ -517,7 +521,7 @@ });

finish(function(data){
finish((data) => {
expect(data.length).to.be.equal(0);
testCase.args.forEach(function(arg) {
if (typeof arg === "function") {
expect(arg.called, "callback must be called").to.be.true;
testCase.args.forEach((arg) => {
if (typeof arg === 'function') {
expect(arg.called, 'callback must be called').to.be.true;
}

@@ -533,10 +537,10 @@ });

it('should not send records is not object', function (done) {
runServer({}, function (server, finish) {
it('should not send records is not object', (done) => {
runServer({}, (server, finish) => {
var s1 = new sender.FluentSender(null, { port: server.port });
s1.on('error', function (error) {
s1.on('error', (error) => {
expect(error.name).to.be.equal('DataTypeError');
});
s1.emit('label', 'string');
finish(function(data) {
finish((data) => {
expect(data.length).to.be.equal(0);

@@ -548,3 +552,3 @@ });

it('should set max listeners', function(done){
it('should set max listeners', (done) => {
var s = new sender.FluentSender('debug');

@@ -564,13 +568,13 @@ if (EventEmitter.prototype.getMaxListeners) {

// Internal behavior test.
it('should not flush queue if existing connection is unavailable.', function(done){
runServer({}, function(server, finish){
it('should not flush queue if existing connection is unavailable.', (done) => {
runServer({}, (server, finish) => {
var s = new sender.FluentSender('debug', {port: server.port});
s.emit('1st record', { message: '1st data' }, function(){
s.emit('1st record', { message: '1st data' }, () => {
s._disconnect();
s.emit('2nd record', { message: '2nd data' }, function(){
finish(function(data){
expect(data[0].tag).to.be.equal("debug.1st record");
expect(data[0].data.message).to.be.equal("1st data");
expect(data[1].tag).to.be.equal("debug.2nd record");
expect(data[1].data.message).to.be.equal("2nd data");
s.emit('2nd record', { message: '2nd data' }, () => {
finish((data) => {
expect(data[0].tag).to.be.equal('debug.1st record');
expect(data[0].data.message).to.be.equal('1st data');
expect(data[1].tag).to.be.equal('debug.2nd record');
expect(data[1].data.message).to.be.equal('2nd data');
done();

@@ -583,4 +587,4 @@ });

it('should write stream.', function(done) {
runServer({}, function(server, finish) {
it('should write stream.', (done) => {
runServer({}, (server, finish) => {
var s = new sender.FluentSender('debug', { port: server.port });

@@ -594,5 +598,5 @@ var ss = s.toStream('record');

pt.end();
ss.on('finish', function() {
s.end(null, null, function() {
finish(function(data) {
ss.on('finish', () => {
s.end(null, null, () => {
finish((data) => {
expect(data[0].data.message).to.be.equal('data1');

@@ -609,4 +613,4 @@ expect(data[1].data.message).to.be.equal('data2');

it('should process messages step by step on requireAckResponse=true', function(done) {
runServer({ requireAckResponse: true }, function(server, finish) {
it('should process messages step by step on requireAckResponse=true', (done) => {
runServer({ requireAckResponse: true }, (server, finish) => {
var s = new sender.FluentSender('debug', {

@@ -619,4 +623,4 @@ port: server.port,

var errors = [];
s.on('error', function(err) {
errors.push(count+': '+err);
s.on('error', (err) => {
errors.push(count + ': ' + err);
});

@@ -623,0 +627,0 @@ var maxCount = 20;

'use strict';
/* globals describe, it */
/* eslint node/no-unpublished-require: ["error", {"allowModules": ["async", "chai", "winston"]}] */
var expect = require('chai').expect;

@@ -7,5 +9,5 @@ var winstonSupport = require('../lib/winston');

describe("winston", function(){
describe('name', function(){
it('should be "fluent"', function(done){
describe('winston', () => {
describe('name', () => {
it('should be "fluent"', (done) => {
expect((new (winstonSupport.Transport)()).name).to.be.equal('fluent');

@@ -16,6 +18,6 @@ done();

describe('transport', function(){
describe('transport', () => {
it('should send log records', function(done){
runServer({}, function(server, finish){
it('should send log records', (done) => {
runServer({}, (server, finish) => {
var logger = new (winston.Logger)({

@@ -29,4 +31,4 @@ transports: [

logger.info('foo %s', 'bar', {x: 1});
setTimeout(function(){
finish(function(data){
setTimeout(() => {
finish((data) => {
expect(data[0].tag).to.be.equal('debug');

@@ -33,0 +35,0 @@ expect(data[0].data).exist;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc