Skip to content

v7.10.0

Compare
Choose a tag to compare
@gajus gajus released this 18 Mar 21:28

7.10.0 (2022-03-18)

Features

If you ever need to test what is getting logged, Roarr (v7.10) now has a neat trick:

const messages = [];

log.adopt(() => {
  yourApplication();
}, (message) => {
  messages.push(message);
});

messages now includes anything that is/will going to be logged by yourApplication (including any of the descending async contexts).

You could even do something like this:

log.adopt(() => {
  httpServer.listen(8080);
}, (message) => {
  messages.push(message);
})

Now messages would get appended to every time that HTTP server handles a request which produces Roarr logs.

Example of where this is useful:

gajus/fastify-webpack-hot@a71a8d8#diff-0fedfd7c9fb1766a8baa39c2f5350d5697dc81cf10fc2065d457242c437104a2R146-R168