有没有办法使用Javascript读取console.log? [英] Is there a way to read the console.log using Javascript?
本文介绍了有没有办法使用Javascript读取console.log?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
标题非常明显。
有没有办法读取输出到console.log的内容,直到你决定阅读它为止,使用Javascript?
Is there a way to read whatever's been output to the console.log up until the moment you decide to read it, using Javascript?
推荐答案
您可以围绕它创建代理,例如:
You can make a proxy around it, such as :
(function(win){
var ncon = win.console;
var con = win.console = {
backlog: []
};
for(var k in ncon) {
if(typeof ncon[k] === 'function') {
con[k] = (function(fn) {
return function() {
con.backlog.push([new Date(), fn, arguments]);
ncon[fn].apply(ncon, arguments);
};
})(k);
}
}
})(window);
这篇关于有没有办法使用Javascript读取console.log?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文