diff --git a/lib/loggly/common.js b/lib/loggly/common.js index 18ad759..1dc8de2 100644 --- a/lib/loggly/common.js +++ b/lib/loggly/common.js @@ -206,11 +206,12 @@ common.loggly = function () { if (timerFunction === null) { timerFunction = setInterval(function () { sendBulkLogs(); + if (timerFunction && !arrMsg.length) { + clearInterval(timerFunction) + timerFunction = null; + } },5000); - } else if (timerFunction && !arrMsg.length) { - clearInterval(timerFunction); - timerFunction = null; - } + } arrMsg.push(requestBody); if (arrMsg.length === arrSize) { sendBulkLogs(); @@ -226,11 +227,12 @@ common.loggly = function () { if (timerFunctionForBufferedLogs === null) { timerFunctionForBufferedLogs = setInterval(function () { if (arrBufferedMsg.length) sendBufferdLogstoLoggly(); + if (timerFunctionForBufferedLogs && !arrBufferedMsg.length) { + clearInterval(timerFunctionForBufferedLogs); + timerFunctionForBufferedLogs = null; + } }, bufferOptions.retriesInMilliSeconds); - } else if (timerFunctionForBufferedLogs && !arrBufferedMsg.length) { - clearInterval(timerFunctionForBufferedLogs); - timerFunctionForBufferedLogs = null; - } + } function sendBufferdLogstoLoggly() {