1

I need to capture the INFO level logs and store them in a variable

enter image description here

console command to fetch all INFO level loggings would be a great help.

Bharath Kumar S
  • 1,410
  • 2
  • 10
  • 29
  • 2
    Does this answer your question? [How to read from Chrome's console in JavaScript](https://stackoverflow.com/questions/19846078/how-to-read-from-chromes-console-in-javascript) – Sudarshan Rai Jan 04 '21 at 16:34

1 Answers1

3

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);
CertainPerformance
  • 356,069
  • 52
  • 309
  • 320