console.log()和console.debug()之间的区别?

时间:2022-08-25 19:44:15

Google has not been helpful for me, since searching for "console.debug" just brings up a bunch of pages that have the words "console" and "debug" on them.

谷歌对我没有帮助,因为搜索“console.debug”只会显示一堆页面上有“控制台”和“调试”字样。

I'm wondering what the difference is between console.log() and console.debug(). Is there some way to use a bunch of console.debug() statements and then just flip a switch to easily shut off all debug statements from being sent to the console (like after launching a site)?

我想知道console.log()和console.debug()之间的区别是什么。有没有办法使用一堆console.debug()语句,然后只需翻转一个开关,轻松关闭所有调试语句发送到控制台(如启动网站后)?

5 个解决方案

#1


50  

For at least IE, Firefox and Chrome consoles, .debug() is just an alias for .log() added for improved compatibility

对于至少IE,Firefox和Chrome控制台,.debug()只是.log()的别名,用于提高兼容性

https://developer.mozilla.org/en-US/docs/Web/API/console

https://developer.mozilla.org/en-US/docs/Web/API/console

https://developers.google.com/chrome-developer-tools/docs/console-api#consoledebugobject_object

https://developers.google.com/chrome-developer-tools/docs/console-api#consoledebugobject_object

https://msdn.microsoft.com/en-us/library/ie/hh772183(v=vs.85).aspx

https://msdn.microsoft.com/en-us/library/ie/hh772183(v=vs.85).aspx

#2


61  

Technically console.log console.debug and console.info are identical However the way they display the data is little different

从技术上讲,console.log console.debug和console.info是相同的但是它们显示数据的方式却略有不同

console.log Black color text with no icon

console.log没有图标的黑色文本

console.info Blue color text with icon

console.info带图标的蓝色文本

console.debug Pure black color text

console.debug纯黑色文字

console.warn Yellow color text with icon

console.warn带图标的黄色文本

console.error Red Color text with icon

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);

console.log()和console.debug()之间的区别?

#3


14  

they are identical except for 1 thing - debug messages are hidden by default in recent versions of Chrome (you have to set log level to Verbose on top of console to see debug messages; you see log messages by default).

它们是相同的,除了一件事 - 默认情况下,调试消息在最新版本的Chrome中隐藏(您必须在控制台顶部将日志级别设置为Verbose以查看调试消息;默认情况下您会看到日志消息)。

#4


10  

console.info ,console.debug methods are identical to console.log.

console.info,console.debug方法与console.log相同。

  • console.log Printing statement
  • console.log打印声明
  • console.info Black color text with "i" icon in blue color
  • console.info黑色文本,蓝色“i”图标
  • console.debug Blue Color text
  • console.debug蓝色文本

Documentation:

文档:

#5


1  

From Documentation of browsers,The log,debugand also info methods are identical in implementation wise but varies in color and icon

从浏览器的文档中,日志,调试和信息方法在实现方面是相同的,但颜色和图标各不相同

https://jsfiddle.net/yp4z76gg/1/

https://jsfiddle.net/yp4z76gg/1/

#1


50  

For at least IE, Firefox and Chrome consoles, .debug() is just an alias for .log() added for improved compatibility

对于至少IE,Firefox和Chrome控制台,.debug()只是.log()的别名,用于提高兼容性

https://developer.mozilla.org/en-US/docs/Web/API/console

https://developer.mozilla.org/en-US/docs/Web/API/console

https://developers.google.com/chrome-developer-tools/docs/console-api#consoledebugobject_object

https://developers.google.com/chrome-developer-tools/docs/console-api#consoledebugobject_object

https://msdn.microsoft.com/en-us/library/ie/hh772183(v=vs.85).aspx

https://msdn.microsoft.com/en-us/library/ie/hh772183(v=vs.85).aspx

#2


61  

Technically console.log console.debug and console.info are identical However the way they display the data is little different

从技术上讲,console.log console.debug和console.info是相同的但是它们显示数据的方式却略有不同

console.log Black color text with no icon

console.log没有图标的黑色文本

console.info Blue color text with icon

console.info带图标的蓝色文本

console.debug Pure black color text

console.debug纯黑色文字

console.warn Yellow color text with icon

console.warn带图标的黄色文本

console.error Red Color text with icon

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);

console.log()和console.debug()之间的区别?

#3


14  

they are identical except for 1 thing - debug messages are hidden by default in recent versions of Chrome (you have to set log level to Verbose on top of console to see debug messages; you see log messages by default).

它们是相同的,除了一件事 - 默认情况下,调试消息在最新版本的Chrome中隐藏(您必须在控制台顶部将日志级别设置为Verbose以查看调试消息;默认情况下您会看到日志消息)。

#4


10  

console.info ,console.debug methods are identical to console.log.

console.info,console.debug方法与console.log相同。

  • console.log Printing statement
  • console.log打印声明
  • console.info Black color text with "i" icon in blue color
  • console.info黑色文本,蓝色“i”图标
  • console.debug Blue Color text
  • console.debug蓝色文本

Documentation:

文档:

#5


1  

From Documentation of browsers,The log,debugand also info methods are identical in implementation wise but varies in color and icon

从浏览器的文档中,日志,调试和信息方法在实现方面是相同的,但颜色和图标各不相同

https://jsfiddle.net/yp4z76gg/1/

https://jsfiddle.net/yp4z76gg/1/