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