Reputation: 23945
I would like to pause the Chrome debugger whenever a console.log statement occurs. Is this possible and if so how would it be achieved?
I know I can break on subtree modification etc. Something like that where the event I was pausing on was one emitted to the console.
Upvotes: 0
Views: 638
Reputation: 371193
One option is to overwrite console.log
with your own function that uses debugger
:
const origConsoleLog = console.log;
console.log = (...args) => {
debugger;
origConsoleLog(...args);
};
(() => {
const foo = 'foo';
console.log('foo is', foo);
const fn = () => {
const someLocalVar = true;
console.log('fn running');
};
fn();
})();
Upvotes: 3