Google一直对我没有帮助,因为搜索“ console.debug”只会弹出一堆带有“ console”和“ debug”字样的页面。
我想知道console.log()
和之间的区别console.debug()
。有什么方法可以使用一堆console.debug()
语句,然后只需轻按一下开关即可轻松地关闭所有调试语句,使其不发送到控制台(例如在启动站点之后)?
至少对于IE,Firefox和Chrome控制台,.debug()只是添加的.log()的别名,以提高兼容性
https://developer.mozilla.org/zh-CN/docs/Web/API/console
https://developers.google.com/chrome-developer-tools/docs/console-api#consoledebugobject_object
https://msdn.microsoft.com/zh-CN/library/ie/hh772183(v=vs.85).aspx
技术上console.log
console.debug
和console.info
是相同的。然而,因为它们显示数据的方式是不同的小
console.log
黑色文字,无图标
console.info
带图标的蓝色文本
console.debug
纯黑色文字
console.warn
带图标的黄色文本
console.error
带图标的红色文本
var playerOne = 120;
var playerTwo = 130;
var playerThree = 140;
var playerFour = 150;
var playerFive = 160;
console.log("Console.log" + " " + playerOne);
console.debug("Console.debug" + " " +playerTwo);
console.warn("Console.warn" + " " + playerThree);
console.info("Console.info" + " " + playerFour);
console.error("Console.error" + " " + playerFive);
它们几乎是相同的-唯一的不同是,调试消息默认情况下在最新版本的Chrome中是隐藏的(您必须Verbose
在控制台中的Devtools顶部栏中将日志级别设置为,才能查看调试消息;默认情况下,日志消息是可见的)。
console.info
,console.debug
方法与相同console.log
。
console.log
印刷声明console.info
黑色文字带有蓝色的“ i”图标console.debug
蓝色文字
说明文件:
If you want the ability to disable logging after a product is finished you could override the console.debug()
function or make another custom one.
console.debug = function() {
if(!console.debugging) return;
console.log.apply(this, arguments);
};
console.debugging = true;
console.debug('Foo', {age:41, name:'Jhon Doe'});
Foo▸ {age: 41, name: "Jhon Doe"}
console.debugging = false;
console.debug('Foo', {age:26, name:'Jane Doe'});
No output
However I havent figured a way to color the outputs as well.
From Documentation of browsers,The log
,debug
and also info
methods are identical in implementation wise but varies in color and icon
文章标签:console , console.log , javascript , web-developer-toolbar
版权声明:本文为原创文章,版权归 javascript 所有,欢迎分享本文,转载请保留出处!
评论已关闭!