Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

chrome > console.info > prints in black ( same as console.log )

Does anyone experience this situation where you do

console.info ('hi'); hi // And this hi is printed in black color as opposed to blue Screenshot from the console: https://postimg.org/image/g8isebbrn/

console.info was used to print in blue for years! Now to my surprise, not anymore.

I could not find any setting on chrome that makes the output go color-blind like that!

like image 839
Average Joe Avatar asked Jan 11 '18 23:01

Average Joe


1 Answers

looks like this is indented by design, go figure, but.. here is a way out as an alternative!

console.log("%cThis will be formatted with large, blue text", "color: blue; font-size: x-large");

do NOT forget the %c in there!

To wrap it in a function, you can use this kick-starter code for you:

function sysConsole(messageType,message){ 
    if ( messageType === 'info') {
      s = '%c' + '##' + messageType + ': ' + message; 
      // the ## will enable you to do filtering at the console 
      // by typing ##info 
      console.log (s, 'color: blue;'); 
    }

    // you can have other messageTypes later (to be wired for different colors )

    return false;
  }

for future inspiration, go to https://developers.google.com/web/tools/chrome-devtools/console/console-write

like image 91
Average Joe Avatar answered Nov 13 '22 05:11

Average Joe