From 4603b4f978ee62149bfd245743e2e9d26144d742 Mon Sep 17 00:00:00 2001 From: sveneh Date: Tue, 3 May 2016 13:04:09 +0200 Subject: [PATCH 1/2] fixed timestamp format according to in_forward specification: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "The time value is a platform specific integer and is based on the output of Ruby’s Time.now.to_i function" http://docs.fluentd.org/articles/in_forward --- lib/sender.js | 2 +- test/test.sender.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/sender.js b/lib/sender.js index a2e40a8..aa2bb7e 100644 --- a/lib/sender.js +++ b/lib/sender.js @@ -83,7 +83,7 @@ FluentSender.prototype._makePacketItem = function(label, data, time){ var tag = label ? [self.tag, label].join('.') : self.tag; if (typeof time != "number") { - time = (time ? time.getTime() : Date.now()) / this._timeResolution; + time = Math.floor((time ? time.getTime() : Date.now()) / this._timeResolution); } var packet = [tag, time, data]; diff --git a/test/test.sender.js b/test/test.sender.js index 0a6efc0..f69fca5 100644 --- a/test/test.sender.js +++ b/test/test.sender.js @@ -64,11 +64,12 @@ describe("FluentSender", function(){ it('should allow to emit with a custom timestamp', function(done){ runServer(function(server, finish){ var s = new sender.FluentSender('debug', {port: server.port}); - var timestamp = new Date(); + var timestamp = new Date(2222, 12, 04); + var timestamp_seconds_since_epoch = Math.floor(timestamp.getTime() / 1000); s.emit("1st record", "1st data", timestamp, function() { finish(function(data) { - expect(data[0].time).to.be.equal(timestamp.getTime() / 1000); + expect(data[0].time).to.be.equal(timestamp_seconds_since_epoch); done(); }); }); @@ -78,7 +79,7 @@ describe("FluentSender", function(){ it('should allow to emit with a custom numeric timestamp', function(done){ runServer(function(server, finish){ var s = new sender.FluentSender('debug', {port: server.port}); - var timestamp = new Date().getTime() / 1000; + var timestamp = Math.floor(new Date().getTime() / 1000); s.emit("1st record", "1st data", timestamp, function() { finish(function(data) { @@ -235,7 +236,7 @@ describe("FluentSender", function(){ expect: { tag: 'debug', data: { bar: 1 }, - time: 1384434467.952 + time: 1384434467 } } ].forEach(function(testCase) { From 04b147ba18649d90a7ffd1e3437da2e30bd55758 Mon Sep 17 00:00:00 2001 From: sveneh Date: Tue, 3 May 2016 13:06:31 +0200 Subject: [PATCH 2/2] cleaned docs, verbose does not exist anymore --- README.md | 6 +----- lib/sender.js | 1 - 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index d8a3e9d..6a0b3c7 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Simple configuration is following: Singleton style var logger = require('fluent-logger') - // The 2nd argument can be omitted. Here is a defualt value for options. + // The 2nd argument can be omitted. Here is a default value for options. logger.configure('tag', { host: 'localhost', port: 24224, @@ -144,10 +144,6 @@ See [socket.setTimeout][2] Set the reconnect interval in milliseconds. If error occurs then reconnect after this interval. -**verbose** - -If set `true`, verbose output. - [1]: https://nodejs.org/api/net.html#net_socket_connect_path_connectlistener [2]: https://nodejs.org/api/net.html#net_socket_settimeout_timeout_callback diff --git a/lib/sender.js b/lib/sender.js index aa2bb7e..5d7857a 100644 --- a/lib/sender.js +++ b/lib/sender.js @@ -13,7 +13,6 @@ function FluentSender(tag, options){ this.path = options.path; this.timeout = options.timeout || 3.0; this.reconnectInterval = options.reconnectInterval || 600000; // Default is 10 minutes - this.verbose = this.verbose || false; this._timeResolution = options.milliseconds ? 1 : 1000; this._socket = null; this._sendQueue = []; // queue for items waiting for being sent.