@madgex/datadog-logger
Advanced tools
Comparing version 1.1.1 to 1.1.2
const DataDogLogger = require('../logger_setup'); | ||
it('Can log using TCP', async () => { | ||
it('Can log using TCP', async done => { | ||
@@ -10,3 +10,3 @@ expect.assertions(1); | ||
dataDog : { | ||
port: 5398, | ||
port: 5301, | ||
hostIp: '127.0.0.1' | ||
@@ -26,7 +26,10 @@ } | ||
logger.end(); | ||
expect(true).toEqual(true); | ||
setTimeout(() => { | ||
logger.end(); | ||
expect(true).toEqual(true); | ||
done(); | ||
}, 3000); | ||
}); | ||
it('Can log using UDP', async () => { | ||
it('Can log using UDP', async done => { | ||
expect.assertions(1); | ||
@@ -38,3 +41,3 @@ | ||
udp: true, | ||
port: 5399, | ||
port: 5302, | ||
hostIp: '127.0.0.1' | ||
@@ -53,5 +56,9 @@ } | ||
logger.info('ddog UDP test 7', options); | ||
logger.end(); | ||
expect(true).toEqual(true); | ||
setTimeout(() => { | ||
logger.end(); | ||
expect(true).toEqual(true); | ||
done(); | ||
}, 3000); | ||
}); |
{ | ||
"name": "@madgex/datadog-logger", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Setup console and Hapi Good logger", | ||
@@ -5,0 +5,0 @@ "main": "logger_setup.js", |
@@ -32,2 +32,3 @@ const assert = require('assert'); | ||
this.entryBuffer = []; | ||
this.udpClient = null; | ||
@@ -60,19 +61,18 @@ if (this.options.enableInternalDebugging) { | ||
const client = dgram.createSocket('udp4'); | ||
while (client && this.entryBuffer.length) { | ||
if(!this.udpClient) { | ||
this.udpClient = dgram.createSocket('udp4'); | ||
} | ||
while (this.udpClient && this.entryBuffer.length) { | ||
const message = this.entryBuffer.pop(); | ||
if (message) { | ||
client.send(message, 0, message.length, this.options.port, this.options.host, (err, bytes) => { | ||
this.udpClient.send(message, 0, message.length, this.options.port, this.options.host, function(err, bytes) { | ||
if (err) { | ||
client = null; | ||
this.close(); | ||
this.internalDebug('writing to buffer', err); | ||
this.entryBuffer.push(bytes); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
if (client) { | ||
client.close(); | ||
} | ||
} | ||
@@ -88,2 +88,9 @@ | ||
} | ||
close() { | ||
if(this.udpClient) { | ||
this.udpClient.close(); | ||
this.udpClient = null; | ||
} | ||
} | ||
}; |
21408
522