3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

logs: batch log messages by default (1000ms)

This commit is contained in:
Dragory 2020-05-22 20:49:57 +03:00
parent 38f71c6d8d
commit 238e66474a
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -189,7 +189,10 @@ export class LogsPlugin extends ZeppelinPlugin<TConfigSchema> {
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<TConfigSchema> {
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);