From aab4a8deff8a8c521b61074f2a3eae73063ba1c3 Mon Sep 17 00:00:00 2001 From: Maurice Butler Date: Tue, 3 Oct 2017 23:23:36 +1000 Subject: [PATCH] Allow bulk messages to be passed as an array --- lib/loggly/client.js | 2 +- lib/loggly/common.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/loggly/client.js b/lib/loggly/client.js index 6cb99c1..a40cb6d 100644 --- a/lib/loggly/client.js +++ b/lib/loggly/client.js @@ -144,7 +144,7 @@ Loggly.prototype.log = function (msg, tags, callback) { } } - msg = serialize(msg); + msg = this.isBulk && Array.isArray(msg) ? msg.map(serialize) : serialize(msg); logOptions = { uri: this.isBulk ? this.urls.bulk : this.urls.log, diff --git a/lib/loggly/common.js b/lib/loggly/common.js index 1dc8de2..654e1e5 100644 --- a/lib/loggly/common.js +++ b/lib/loggly/common.js @@ -212,7 +212,13 @@ common.loggly = function () { } },5000); } - arrMsg.push(requestBody); + + if (Array.isArray(requestBody)) { + arrMsg.push.apply(arrMsg, requestBody); + } else { + arrMsg.push(requestBody); + } + if (arrMsg.length === arrSize) { sendBulkLogs(); }