将Chrome开发控制台转储到文本文件? [英] Dump Chrome dev console to text file?

查看:163
本文介绍了将Chrome开发控制台转储到文本文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时,当我尝试调试用户使用Chrome扩展程序(StayFocusd)的问题时,访问控制台日志将非常有用。现在我只是要求他们将日志复制粘贴到我,但如果我可以通过编程方式生成一个可以发给我的文件,那会更好一些。这是可能的吗?



另外,至少可以用Javascript捕获控制台内容,所以我可以为自己输出一个有用的调试格式?

解决方案

有一个实验API: chrome.experimental.devtools.console

  chrome.experimental.devtools.console.getMessages(function(messages){
messages [0] .url // http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery .min.js
消息[0] .text // XHR完成加载
消息[0] .line // 4
})
/ pre>

Sometimes when I'm trying to debug an issue a user is having with my Chrome extension (StayFocusd), it would be useful to have access to the console logs. Right now I just ask them to copy-and-paste the log to me, but it would be nicer if I could programatically generate a file they could just email to me. Is that possible?

Alternately, is at least possible to capture the console contents with Javascript so I could output it to a useful debugging format for myself?

解决方案

There is an experimental API for that: chrome.experimental.devtools.console:

chrome.experimental.devtools.console.getMessages(function(messages) {
    messages[0].url  // http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js
    messages[0].text // XHR finished loading
    messages[0].line // 4
})

这篇关于将Chrome开发控制台转储到文本文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆