New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

logzio-nodejs

Package Overview
Dependencies
Maintainers
4
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logzio-nodejs - npm Package Compare versions

Comparing version 0.4.13 to 0.4.14

.eslintrc.js

15

lib/logzio-nodejs.js

@@ -84,3 +84,3 @@ var request = require('request');

this.callback = callback || this._defaultCallback;
this._debug("Sending last messages and closing...");
this._debug('Sending last messages and closing...');
this._popMsgsAndSend();

@@ -113,3 +113,3 @@ clearTimeout(this.timer);

self._debug('Error while sending udp packets. err = ' + err);
callback(new Error('Failed to send udp log message. err = ' + err));
self.callback(new Error('Failed to send udp log message. err = ' + err));
}

@@ -132,12 +132,13 @@ };

clearTimeout(this.timer);
if (this.protocol === 'udp') {
this.udpClient.close();
}
// send pending messages, if any
if (this.messages.length > 0) {
this._debug("Closing, purging messages.");
this._debug('Closing, purging messages.');
this._popMsgsAndSend();
}
if (this.protocol === 'udp') {
this.udpClient.close();
}
// no more logging allowed

@@ -259,3 +260,3 @@ this.closed = true;

bulk.attemptNumber++;
tryAgainIn(sleepTimeMs)
tryAgainIn(sleepTimeMs);
}

@@ -262,0 +263,0 @@ }

{
"name": "logzio-nodejs",
"description": "A nodejs implementation for sending logs to Logz.IO cloud service",
"version": "0.4.13",
"version": "0.4.14",
"author": "Gilly Barr <gilly@logz.io>",

@@ -44,2 +44,3 @@ "contributors": [

"async": "1.4.2",
"eslint": "^5.0.1",
"mocha": "^5.2.0",

@@ -46,0 +47,0 @@ "nock": "^9.4.0",

@@ -58,2 +58,7 @@ ![Build Status](https://travis-ci.org/logzio/logzio-nodejs.svg?branch=master)

## Update log
**0.4.14**
- UDP callback bug fix + tests
- UDP close connection bug fix + tests
- ESLint
**0.4.12**

@@ -60,0 +65,0 @@ - Updated ability to add custom port

@@ -1,2 +0,2 @@

var sinon = require('sinon');
var sinon = require('sinon');
var logzioLogger = require('../lib/logzio-nodejs.js');

@@ -11,3 +11,3 @@ var request = require('request');

var createLogger = function(options) {
var createLogger = function (options) {
var myoptions = options;

@@ -23,13 +23,13 @@ myoptions.token = 'acrSGIefherhsZYOpzxeGBpTyqgSzaMk';

describe('logger', function() {
describe('logger', function () {
describe('logs a single line', function () {
before(function(done){
before(function (done) {
sinon
.stub(request, 'post')
.yields(null, {statusCode: 200}, '');
.yields(null, { statusCode: 200 }, '');
done();
});
after(function(done){
after(function (done) {
request.post.restore();

@@ -43,3 +43,3 @@ done();

logger = createLogger({
bufferSize: 1,
bufferSize: 1,
callback: done

@@ -57,7 +57,7 @@ });

it('sends log as a string with extra fields', function(done) {
it('sends log as a string with extra fields', function (done) {
var logger = createLogger({
bufferSize:1,
bufferSize: 1,
callback: done,
extraFields:{
extraFields: {
extraField1: 'val1',

@@ -79,3 +79,3 @@ extraField2: 'val2'

it('sends log as an object', function (done) {
var logger = createLogger({bufferSize:1, callback: done});
var logger = createLogger({ bufferSize: 1, callback: done });
sinon.spy(logger, '_createBulk');

@@ -91,7 +91,7 @@

it('sends log as an object with extra fields', function(done) {
it('sends log as an object with extra fields', function (done) {
var logger = createLogger({
bufferSize:1,
bufferSize: 1,
callback: done,
extraFields:{
extraFields: {
extraField1: 'val1',

@@ -112,6 +112,6 @@ extraField2: 'val2'

it('adds nano seconds when added to options', function(done) {
it('adds nano seconds when added to options', function (done) {
// testing without nano seconds
var logger = createLogger({
bufferSize:1
bufferSize: 1
});

@@ -127,4 +127,4 @@ sinon.spy(logger, '_createBulk');

// testing with nano seconds
var logger = createLogger({
bufferSize:1,
logger = createLogger({
bufferSize: 1,
callback: done,

@@ -141,10 +141,10 @@ addTimestampWithNanoSecs: true

});
it('writes a log message without @timestamp', function(done) {
it('writes a log message without @timestamp', function (done) {
var logger = createLogger({
// buffer is 2 so we could access the log before we send it, to analyze it
bufferSize:2,
bufferSize: 2,
callback: done
});
var fakeTime = moment("2011-09-01").valueOf();
var fakeTime = moment('2011-09-01').valueOf();

@@ -156,17 +156,17 @@ // Fake the current time, so we could test on it

assert.equal(fakeTime, moment(logger.messages[logger.messages.length-1]['@timestamp'].valueOf()));
assert.equal(fakeTime, moment(logger.messages[logger.messages.length - 1]['@timestamp'].valueOf()));
logger.close();
});
it('writes a log message with a custom @timestamp', function(done) {
it('writes a log message with a custom @timestamp', function (done) {
var logger = createLogger({
// buffer is 2 so we could access the log before we send it, to analyze it
bufferSize:2,
bufferSize: 2,
callback: done
});
var fakeTime = moment("2011-09-01");
var fakeTime = moment('2011-09-01');
logger.log({ message: 'hello there from test', '@timestamp': fakeTime.format()});
logger.log({ message: 'hello there from test', '@timestamp': fakeTime.format() });
assert.equal(fakeTime.format(), logger.messages[logger.messages.length-1]['@timestamp']);
assert.equal(fakeTime.format(), logger.messages[logger.messages.length - 1]['@timestamp']);
logger.close();

@@ -177,10 +177,10 @@ });

describe('logs multiple lines', function () {
before(function(done){
before(function (done) {
sinon
.stub(request, 'post')
.yields(null, {statusCode: 200} , '');
.yields(null, { statusCode: 200 }, '');
done();
});
after(function(done){
after(function (done) {
request.post.restore();

@@ -191,3 +191,3 @@ done();

it('Send multiple lines', function (done) {
var logger = createLogger({ bufferSize: 3, callback: done });

@@ -209,7 +209,6 @@

if (expectedTimes == timesCalled)
if (expectedTimes == timesCalled) {
done();
else if (timesCalled > expectedTimes) {
fail('called more than expected');
done();
} else if (timesCalled > expectedTimes) {
throw 'called more than expected';
}

@@ -219,3 +218,3 @@ }

var logger = createLogger({
bufferSize: 3,
bufferSize: 3,
callback: assertCalled

@@ -236,10 +235,10 @@ });

describe('#log-closing', function () {
before(function(done){
before(function (done) {
sinon
.stub(request, 'post')
.yields(null, {statusCode: 200} , "");
.yields(null, { statusCode: 200 }, '');
done();
});
after(function(done){
after(function (done) {
request.post.restore();

@@ -250,9 +249,9 @@ done();

it('Don\'t allow logs after closing', function (done) {
var logger = createLogger({bufferSize:1});
var logger = createLogger({ bufferSize: 1 });
logger.close();
try {
logger.log({messge:"hello there from test"});
done("Expected an error when logging into a closed log!");
logger.log({ messge: 'hello there from test' });
done('Expected an error when logging into a closed log!');
} catch (ex) {
done();
done();
}

@@ -263,10 +262,10 @@ });

describe('timers', function () {
before(function(done){
before(function (done) {
sinon
.stub(request, 'post')
.yields(null, {statusCode: 200} , "");
.yields(null, { statusCode: 200 }, '');
done();
});
after(function(done){
after(function (done) {
request.post.restore();

@@ -287,4 +286,5 @@ done();

}
var logger = createLogger({
bufferSize: 100,
var logger = createLogger({
bufferSize: 100,
callback: assertCalled,

@@ -300,11 +300,11 @@ sendIntervalMs: 5000

// Schedule 100 msgs (buffer size) which should be sent in one bulk 11 seconds from start
setTimeout(function() {
setTimeout(function () {
for (var i = 0; i < 100; i++) {
logger.log({
messge: 'hello there from test',
testid: 6
logger.log({
messge: 'hello there from test',
testid: 6
});
}
logger.close();
}, 6000)
}, 6000);

@@ -320,3 +320,3 @@ });

before(function(done){
before(function (done) {
nock.cleanAll();

@@ -338,3 +338,3 @@ errorAndThenSuccessScope = nock(nockHttpAddress)

extraRequestScope = nock(nockHttpAddress)
.filteringPath(function() {
.filteringPath(function () {
return '/';

@@ -349,3 +349,3 @@ })

after(function(done){
after(function (done) {
nock.restore();

@@ -360,12 +360,12 @@ nock.cleanAll();

var logger = createLogger({ bufferSize: 1, sendIntervalMs: 50000, timeout: 1000 });
logger.log({ messge: 'hello there from test', testid: 5 });
logger.close();
setTimeout(function() {
if (!errorAndThenSuccessScope.isDone()) {
setTimeout(function () {
if (!errorAndThenSuccessScope.isDone()) {
done(new Error('pending mocks: ' + errorAndThenSuccessScope.pendingMocks()));
} else {
if (extraRequestScope.isDone()) {
done(new Error('We don\'t expect another request'))
done(new Error('We don\'t expect another request'));
} else {

@@ -375,3 +375,3 @@ done();

}
}, 10000);
}, 10000);
});

@@ -382,10 +382,10 @@

describe('bad request', function () {
before(function(done){
before(function (done) {
sinon
.stub(request, 'post')
.yields(null, {statusCode: 400} , "bad");
.yields(null, { statusCode: 400 }, 'bad');
done();
});
after(function(done){
after(function (done) {
request.post.restore();

@@ -396,54 +396,18 @@ done();

it('bad request test', function (done) {
var logger = createLogger({bufferSize:3, callback: function(err) {
if (err) {
done();
return;
}
done('Expected an error');
}});
logger.log({messge:"hello there from test", testid:2});
logger.log({messge:"hello there from test2", testid:2});
logger.log({messge:"hello there from test3", testid:2});
logger.close();
});
});
describe('sending udp', function() {
it('sends single log', function(done) {
var logger = createLogger({
bufferSize: 1,
protocol: 'udp'
});
bufferSize: 3, callback: function (err) {
if (err) {
done();
return;
}
var udpSentCounter = 0;
sinon.stub(logger.udpClient, 'send', function() { udpSentCounter++; });
logger.log('hello from the other side');
assert(udpSentCounter === 1);
logger.close();
done();
});
it('sends multiple logs', function(done) {
var logger = createLogger({
bufferSize: 2,
protocol: 'udp'
done('Expected an error');
}
});
var udpSentCounter = 0;
sinon.stub(logger.udpClient, 'send', function() { udpSentCounter++; });
logger.log('hello from the other side');
logger.log('hello from the other side');
logger.log('hello from the other side');
logger.log('hello from the other side');
assert(udpSentCounter === 4);
logger.log({ messge: 'hello there from test', testid: 2 });
logger.log({ messge: 'hello there from test2', testid: 2 });
logger.log({ messge: 'hello there from test3', testid: 2 });
logger.close();
done();
});
});
});
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