@gvray/logger / batchMiddleware
Function: batchMiddleware()
batchMiddleware(
options):LogMiddleware
Defined in: middleware/batch.ts:38
Middleware that collects log entries into batches and flushes them together.
Each log is still forwarded to output (via next()) as it happens; additionally, contexts are accumulated and passed to onFlush when either maxSize is reached or maxWait milliseconds elapse since the first entry of the batch. Useful for collecting entries for deferred in-process handling (e.g., a debug summary or on-screen panel).
Parameters
options
Batch configuration, including the flush handler.
Returns
A LogMiddleware instance.
Example
ts
logger.use(
batchMiddleware({
maxSize: 10,
maxWait: 5000,
onFlush: (ctxs) => sendToServer(ctxs),
}),
);