Javascript有什么调试日志工具? [英] What debug logging tools are available from Javascript?

查看:134
本文介绍了Javascript有什么调试日志工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个通用调试日志记录功能,用于检查知名日志记录库的JS命名空间。

I'd like to create a "universal" debug logging function that inspects the JS namespace for well-known logging libraries.

例如,目前它支持Firebug console.log:

For example, currently it supports Firebug's console.log:

var console = window['console'];
if (console && console.log) {
  console.log(message);
}

显然,只有在Firebug安装/也可以在其他浏览器上使用 Firebug Lite )。基本上,我将提供一个JS库,我不知道它会被拉入到什么环境,我想要能够找出是否有一种方法来报告调试输出给用户。

Obviously, this only works in Firefox if Firebug is installed/enabled (it'll also work on other browsers with Firebug Lite). Basically, I will be providing a JS library which I don't know what environment it will be pulled into, and I'd like to be able to figure out if there is a way to report debug output to the user.

所以,也许jQuery提供了一些东西 - 我会检查jQuery是否存在并使用它。或者也许有知名的IE插件工作,我可以嗅探。但它必须是一个相当完善和使用的机制。我不能检查人们创建的每一个模糊日志函数。

So, perhaps jQuery provides something - I'd check that jQuery is present and use it. Or maybe there are well-known IE plugins that work that I can sniff for. But it has to be a fairly well-established and used mechanism. I can't check for every obscure log function that people create.

请每个答案只有一个库/技术,所以他们可以获得排名。此外,使用alert()是一个很好的短期解决方案,但如果你想要强大的调试日志记录或阻塞执行是一个问题,则会中断。

Please, only one library/technology per answer, so they can get vote-ranked. Also, using alert() is a good short-term solution but breaks down if you want robust debug logging or if blocking the execution is a problem.

推荐答案

您可以尝试 log4javascript

披露:我写了。

这篇关于Javascript有什么调试日志工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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