Socket
Socket
Sign inDemoInstall

fluent-logger

Package Overview
Dependencies
5
Maintainers
4
Versions
46
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.2.3 to 3.3.0

6

CHANGELOG.md
# v3.x
## v3.3.0 - 2019-01-31
### Improvements
* Improve performance #131
## v3.2.3 - 2019-01-10

@@ -4,0 +10,0 @@

4

lib/event-time.js

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

static pack(eventTime) {
const b = Buffer.alloc(8);
const b = Buffer.allocUnsafe(8);
b.writeUInt32BE(eventTime.epoch, 0);

@@ -35,5 +35,5 @@ b.writeUInt32BE(eventTime.nano, 4);

const epoch = Math.floor(t / 1000);
const nano = (t - epoch * 1000) * 1000000;
const nano = t % 1000 * 1000000;
return new EventTime(epoch, nano);
}
};

@@ -12,2 +12,4 @@ 'use strict';

sender._setupErrorHandler();
// Optimization -- see note at end
module.exports.emit = sender.emit.bind(sender);
},

@@ -32,7 +34,7 @@

// delegate logger interfaces to default sender object
const methods = ['emit', 'end', 'addListener', 'on', 'once', 'removeListener', 'removeAllListeners', 'setMaxListeners', 'getMaxListeners'];
const methods = ['end', 'addListener', 'on', 'once', 'removeListener', 'removeAllListeners', 'setMaxListeners', 'getMaxListeners'];
methods.forEach((attr, i) => {
module.exports[attr] = function() {
if (sender) {
return sender[attr].apply(sender, Array.from(arguments));
return sender[attr].apply(sender, arguments);
}

@@ -42,1 +44,4 @@ return undefined;

});
// Export emit() directly so that calls to it can be inlined properly.
module.exports.emit = sender.emit.bind(sender);

@@ -62,21 +62,27 @@ 'use strict';

emit(/*[label] <data>, [timestamp], [callback] */) {
emit(/*[label] <data>, [timestamp], [callback] */a0, a1, a2, a3) {
let label, data, timestamp, callback;
let args = Array.from(arguments);
let timestampOrCallback, cbArg;
// Label must be string always
if (typeof args[0] === 'string') {
label = args.shift();
}
// Data can be almost anything
data = args.shift();
// Date can be either timestamp number or Date object
if (typeof args[0] !== 'function') {
timestamp = args.shift();
// Last argument is an optional callback
if (typeof a0 === 'string') {
label = a0;
data = a1;
timestampOrCallback = a2;
cbArg = a3;
} else {
data = a0;
timestampOrCallback = a1;
cbArg = a2;
}
// Last argument is an optional callback
if (typeof args[0] === 'function') {
callback = args.shift();
if (typeof timestampOrCallback === 'function') {
callback = timestampOrCallback;
} else if (timestampOrCallback) {
timestamp = timestampOrCallback;
if (typeof cbArg === 'function') {
callback = cbArg;
}
}

@@ -142,3 +148,3 @@

if (this.tag_prefix && label) {
tag = [this.tag_prefix, label].join('.');
tag = `${this.tag_prefix}.${label}`;
} else if (this.tag_prefix) {

@@ -153,3 +159,3 @@ tag = this.tag_prefix;

_makePacketItem(tag, time, data) {
if (typeof time !== 'number' && !(time instanceof EventTime)) {
if (!time || (typeof time !== 'number' && !(time instanceof EventTime))) {
time = Math.floor((time ? time.getTime() : Date.now()) / this._timeResolution);

@@ -176,3 +182,3 @@ }

_makeEventEntry(time, data) {
if (typeof time !== 'number' && !(time instanceof EventTime)) {
if (!time || (typeof time !== 'number' && !(time instanceof EventTime))) {
time = Math.floor((time ? time.getTime() : Date.now()) / this._timeResolution);

@@ -196,7 +202,7 @@ }

let eventEntryData = this._sendQueue.get(tag);
eventEntryData.eventEntry = Buffer.concat([eventEntryData.eventEntry, eventEntry]);
eventEntryData.callbacks.push(callback);
this._sendQueue.set(tag, eventEntryData);
eventEntryData.eventEntries.push(eventEntry);
if (callback) eventEntryData.callbacks.push(callback);
} else {
this._sendQueue.set(tag, { eventEntry: eventEntry, callbacks: [callback] });
const callbacks = callback ? [callback] : [];
this._sendQueue.set(tag, { eventEntries: [eventEntry], callbacks: callbacks });
}

@@ -211,24 +217,15 @@ }

this._connecting = true;
process.nextTick(() => {
if (this._socket === null) {
this._doConnect(() => {
this._connecting = false;
callback();
});
} else {
if (!this._socket.writable) {
this._disconnect();
process.nextTick(() => {
this._connecting = false;
this._connect(callback);
});
} else {
process.nextTick(() => {
this._connecting = false;
callback();
});
}
}
});
if (this._socket === null) {
this._connecting = true;
this._doConnect(() => {
this._connecting = false;
callback();
});
} else if (!this._socket.writable) {
this._disconnect();
this._connect(callback);
} else {
this._connecting = false;
process.nextTick(callback);
}
}

@@ -314,3 +311,3 @@

this._status = 'pingpong';
this._socket.write(Buffer.from(this._generatePing()), () => {
this._socket.write(this._generatePing(), () => {
this._socket.resume();

@@ -339,5 +336,3 @@ this._socket.once('data', (data) => {

this._flushingSendQueue = true;
process.nextTick(() => {
this._waitToWrite();
});
this._waitToWrite();
}

@@ -386,6 +381,7 @@

}
let tag = Array.from(this._sendQueue.keys())[0];
let eventEntryData = this._sendQueue.get(tag);
let entries = eventEntryData.eventEntry;
let size = eventEntryData.eventEntry.length;
let first = this._sendQueue.entries().next().value;
let tag = first[0];
let eventEntryData = first[1];
let entries = Buffer.concat(eventEntryData.eventEntries, this._sendQueueSize);
let size = entries.length;
this._sendQueue.delete(tag);

@@ -408,3 +404,3 @@ if (this._compressed) {

const sendQueueSize = this._sendQueueSize;
this._socket.write(Buffer.from(packet), () => {
this._socket.write(packet, () => {
if (this.requireAckResponse) {

@@ -507,3 +503,3 @@ this._socket.once('data', (data) => {

const ping = ['PING', this.security.clientHostname, this.sharedKeySalt, sharedKeyHexdigest];
if (Buffer.isBuffer(this.authentication) && Buffer.byteLength(this.authentication) !== 0) {
if (Buffer.isBuffer(this.authentication) && this.authentication.length !== 0) {
const passwordHexDigest = crypto.createHash('sha512')

@@ -510,0 +506,0 @@ .update(this.authentication)

{
"name": "fluent-logger",
"version": "3.2.3",
"version": "3.3.0",
"main": "./lib/index.js",

@@ -38,7 +38,7 @@ "scripts": {

"async": "*",
"chai": "",
"chai": "*",
"eslint": "^5.1.0",
"eslint-plugin-node": "*",
"mocha": "*",
"selfsigned": "",
"selfsigned": "*",
"winston": "*"

@@ -45,0 +45,0 @@ },

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

expect(data[0].data.level).to.be.equal('info');
expect(data[0].data.meta.x).to.be.equal(1);
expect(data[0].data.x).to.be.equal(1);
done();

@@ -41,0 +41,0 @@ });

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc