fluentd-node
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -79,3 +79,6 @@ import EventTime from "./event_time"; | ||
* | ||
* Defaults to false (seconds). If true, the resolution will be in milliseconds | ||
* Passing false here means that the timestamps will be emitted as numbers (unless you explicitly provide an EventTime) | ||
* Passing true means that timestamps will alwyas be emitted as EventTime object instances. This includes timestamps | ||
* | ||
* Defaults to false (seconds). If true, the resolution will be in milliseconds. | ||
*/ | ||
@@ -134,3 +137,3 @@ milliseconds?: boolean; | ||
private sendQueue; | ||
private timeResolution; | ||
private milliseconds; | ||
private retrier; | ||
@@ -172,3 +175,3 @@ private socket; | ||
* @param data The event to emit (required) | ||
* @param timestamp The timestamp of the event (optional) | ||
* @param timestamp A millisecond resolution timestamp to associate with the event (optional) | ||
* @returns A Promise, which resolves when the event is successfully sent to the server. | ||
@@ -192,3 +195,3 @@ * Enabling acknowledgements waits until the server indicates they have received the event. | ||
* @param data The event to emit (required) | ||
* @param timestamp The timestamp of the event (optional) | ||
* @param timestamp A millisecond resolution timestamp to associate with the event (optional) | ||
* @returns A Promise, which resolves when the event is successfully sent to the server. | ||
@@ -195,0 +198,0 @@ * Enabling acknowledgements waits until the server indicates they have received the event. |
@@ -55,3 +55,3 @@ "use strict"; | ||
}; | ||
this.timeResolution = options.milliseconds ? 1 : 1000; | ||
this.milliseconds = !!options.milliseconds; | ||
this.flushInterval = options.flushInterval || 0; | ||
@@ -140,9 +140,18 @@ this.sendQueueFlushLimit = { | ||
} | ||
let millisOrEventTime; | ||
if (timestamp === null || timestamp instanceof Date) { | ||
millisOrEventTime = timestamp ? timestamp.getTime() : Date.now(); | ||
} | ||
else { | ||
millisOrEventTime = timestamp; | ||
} | ||
let time; | ||
if (timestamp === null || | ||
(typeof timestamp !== "number" && !(timestamp instanceof event_time_1.default))) { | ||
time = Math.floor((timestamp ? timestamp.getTime() : Date.now()) / this.timeResolution); | ||
if (typeof millisOrEventTime === "number") { | ||
// Convert timestamp to EventTime or number in second resolution | ||
time = this.milliseconds | ||
? event_time_1.default.fromTimestamp(millisOrEventTime) | ||
: Math.floor(millisOrEventTime / 1000); | ||
} | ||
else { | ||
time = timestamp; | ||
time = millisOrEventTime; | ||
} | ||
@@ -149,0 +158,0 @@ if (this.retrier !== null) { |
{ | ||
"name": "fluentd-node", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "A fluent protocol implementation in node", | ||
@@ -5,0 +5,0 @@ "main": "./build/src/index.js", |
@@ -109,3 +109,6 @@ import { | ||
* | ||
* Defaults to false (seconds). If true, the resolution will be in milliseconds | ||
* Passing false here means that the timestamps will be emitted as numbers (unless you explicitly provide an EventTime) | ||
* Passing true means that timestamps will alwyas be emitted as EventTime object instances. This includes timestamps | ||
* | ||
* Defaults to false (seconds). If true, the resolution will be in milliseconds. | ||
*/ | ||
@@ -166,3 +169,3 @@ milliseconds?: boolean; | ||
private sendQueue: Queue; | ||
private timeResolution: number; | ||
private milliseconds: boolean; | ||
private retrier: EventRetrier | null; | ||
@@ -215,3 +218,3 @@ | ||
}; | ||
this.timeResolution = options.milliseconds ? 1 : 1000; | ||
this.milliseconds = !!options.milliseconds; | ||
@@ -278,3 +281,3 @@ this.flushInterval = options.flushInterval || 0; | ||
* @param data The event to emit (required) | ||
* @param timestamp The timestamp of the event (optional) | ||
* @param timestamp A millisecond resolution timestamp to associate with the event (optional) | ||
* @returns A Promise, which resolves when the event is successfully sent to the server. | ||
@@ -298,3 +301,3 @@ * Enabling acknowledgements waits until the server indicates they have received the event. | ||
* @param data The event to emit (required) | ||
* @param timestamp The timestamp of the event (optional) | ||
* @param timestamp A millisecond resolution timestamp to associate with the event (optional) | ||
* @returns A Promise, which resolves when the event is successfully sent to the server. | ||
@@ -360,12 +363,18 @@ * Enabling acknowledgements waits until the server indicates they have received the event. | ||
} | ||
let millisOrEventTime: number | EventTime; | ||
if (timestamp === null || timestamp instanceof Date) { | ||
millisOrEventTime = timestamp ? timestamp.getTime() : Date.now(); | ||
} else { | ||
millisOrEventTime = timestamp; | ||
} | ||
let time: protocol.Time; | ||
if ( | ||
timestamp === null || | ||
(typeof timestamp !== "number" && !(timestamp instanceof EventTime)) | ||
) { | ||
time = Math.floor( | ||
(timestamp ? timestamp.getTime() : Date.now()) / this.timeResolution | ||
); | ||
if (typeof millisOrEventTime === "number") { | ||
// Convert timestamp to EventTime or number in second resolution | ||
time = this.milliseconds | ||
? EventTime.fromTimestamp(millisOrEventTime) | ||
: Math.floor(millisOrEventTime / 1000); | ||
} else { | ||
time = timestamp; | ||
time = millisOrEventTime; | ||
} | ||
@@ -372,0 +381,0 @@ if (this.retrier !== null) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
286472
6774