Capture all the logs

1 · Gleb Bahmutov · July 5, 2019, 4 a.m.
In this blog post I will show how to intercept messages logged by a Node process using a pre-loaded module. You can find the source code for these examples in bahmutov/capture-logs-example repository.Capture console logsImagine you want to collect all strings logged from a Node program. You could proxy all console.log calls and store them until needed. Take an example Node program like this one in index.js:index.js123console.log('this is %s log message ✅', 'console')console.warn('this is console...