I need to capture the INFO level logs and store them in a variable
console command to fetch all INFO level loggings would be a great help.
I need to capture the INFO level logs and store them in a variable
console command to fetch all INFO level loggings would be a great help.
Overwrite console.log
with your own implementation that saves the argument(s) as needed, then calls the original console.log
:
const logArgs = [];
const origConsoleLog = console.log;
console.log = (...args) => {
logArgs.push(args);
origConsoleLog(...args);
};
console.log('foo');
console.log('bar');
console.dir(logArgs);