From 238e66474ae5130c1f5ad3eb33a0ad4856563d59 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Fri, 22 May 2020 20:49:57 +0300 Subject: [PATCH] logs: batch log messages by default (1000ms) --- backend/src/plugins/Logs.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/src/plugins/Logs.ts b/backend/src/plugins/Logs.ts index 906db287..a8cc8e1a 100644 --- a/backend/src/plugins/Logs.ts +++ b/backend/src/plugins/Logs.ts @@ -189,7 +189,10 @@ export class LogsPlugin extends ZeppelinPlugin { const message = await this.getLogMessage(type, data); if (message) { - if (opts.batched) { + const batched = opts.batched ?? true; // Default to batched unless explicitly disabled + const batchTime = opts.batch_time ?? 1000; + + if (batched) { // If we're batching log messages, gather all log messages within the set batch_time into a single message if (!this.batches.has(channel.id)) { this.batches.set(channel.id, []); @@ -197,7 +200,7 @@ export class LogsPlugin extends ZeppelinPlugin { const batchedMessage = this.batches.get(channel.id).join("\n"); this.batches.delete(channel.id); createChunkedMessage(channel, batchedMessage).catch(noop); - }, opts.batch_time || 2000); + }, batchTime); } this.batches.get(channel.id).push(message);