Predicate for Logs
First off thank you for the excellent library. It is amazingly helpful for mocking endpoints.
I have certain requests which are fired over and over again (for example an autosave endpoint, or polling the server for some information). I find logging very useful but I would like a way to filter out some of these more common requests. I saw the implementation of quiet in https://github.com/mswjs/msw/issues/111. Would it be possible to extend that concept to use a function which returns True for requests which should be logged and False for requests which should not be logged? The alternative I can think of is to override console.log which is probably less desirable.
Hey, @lukesmurray. Thank you for the feedback!
I see no harm in us extending the quiet option to support a predicate function as a value.
worker.start({
quiet(req, res) {
// Conditionally suppress logs for certain requests.
return req.url.href.includes('/foo')
}
})
Would this suit your usage? If so, are you interested in making a pull request with these changes? I'll support you through the process to make sure we land an awesome extension.
Can pick this up if @lukesmurray isn't. :)
That is exactly what I imagined. Happy to let @balavishnuvj take this one.