Difference between console.log () and console.debug ()?

Google did not help me, as the search for “console.debug” simply brings up a bunch of pages with the words “console” and “debug” on it.

I am wondering what is the difference between console.log() and console.debug() . Is there a way to use a bunch of console.debug() statements, and then just flip the switch to easily disconnect all debugging instructions from sending to the console (for example, after starting the site)?

+111
javascript console web-developer-toolbar
Feb 19 '14 at 9:40
source share
6 answers
+64
Feb 19 '14 at 9:45
source share

Technically, console.log console.debug and console.info identical. However, the way the data is displayed is slightly different

console.log Text in black without an icon

console.info Blue colored text with an icon

console.debug Pure black text

console.warn Yellow colored text with an icon

console.error Red colored text with an icon

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

enter image description here

+84
Apr 01 '16 at 11:19
source share

They are almost identical - the only difference is that debugging messages are hidden by default in recent versions of Chrome (to view debugging messages, you need to set the Verbose log level in the top panel of Devtools, and in the console log messages ;,

+22
May 03 '17 at 17:37
source share

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

  • console.log Printout of statement
  • console.info black color of the text with the "i" icon is blue
  • console.debug Blue Text color

Documentation:

+13
Dec 31 '15 at 5:36
source share

If you want to turn off logging after the product finishes, you can override the console.debug() function or create another custom function.

 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 exit

However, I have not found a way to colorize the results.

+2
Nov 17 '18 at 21:04
source share

From the browser documentation, the log , debug , and info methods are identical in the implementation wise, but differ in color and icon.

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

+1
Jan 29 '16 at 8:30
source share



All Articles