Listening console.log

前端 未结 2 1066
感动是毒
感动是毒 2020-12-09 05:55

I want to set a listener for console.log() and do something with the message without preventing the default behaviour. So, the console of the dev tools should g

2条回答
  •  生来不讨喜
    2020-12-09 06:32

    This is a small hack, but I'm not sure there is a better solution:

    console._log_old = console.log
    console.log = function(msg) {
        alert(msg);
        console._log_old(msg);
    }
    

提交回复
热议问题