winstonjs / winston

A logger for just about everything.
http://github.com/winstonjs/winston
MIT License
22.77k stars 1.81k forks source link

Throttling Support[Feature Request]: #2299

Open dulara1994 opened 1 year ago

dulara1994 commented 1 year ago

🔎 Search Terms

throttling, rate limiting

The vision

In some cases, logging could be costly, it would be better to have a mechanism to rate limit, or throttle number of logger calls per second.

Use case

I should be able to rate limit/ throttle the logger.

eg: 100 logger calls per second.

once it reaches the threshold, it shouldn't log any. but at the end of that second, it should log the following.

throttled n messages

where n = no of requests which didn't log due to throttling.

Additional information

No response

wbt commented 1 year ago

Seems like a good idea in theory.
It might be better to implement this as a separate package that wraps around Winston instead; not sure. (That strategy is probably the fastest route to actually getting the functionality in this community-maintained project though!)