Skip to content

@gvray/logger


@gvray/logger / throttleMiddleware

Function: throttleMiddleware() ​

throttleMiddleware(options): LogMiddleware

Defined in: middleware/throttle.ts:29

Middleware that rate-limits log output.

Within each interval window, at most limit log entries sharing the same level and first argument are forwarded; the rest are dropped. The counter resets after the window elapses.

Parameters ​

options ​

ThrottleOptions

Throttle configuration.

Returns ​

LogMiddleware

A LogMiddleware instance.

Example ​

ts
logger.use(throttleMiddleware({ limit: 2, interval: 1000 }));
for (let i = 0; i < 5; i++) logger.info('spam'); // only 2 output per second

Released under the MIT License.