0
votes

In google chrome, I'm trying to add colors to console.logs using css, but I'm facing a problem with line breaks.

in a simple console log, \n works just fine: enter image description here

but it somehow gets ignored when I add styles: enter image description here

do you know why this is happening? and how I can solve it without making several calls to console.log?

which version of chrome are you using ? I tried console.log('%c%s%c \n b', 'color: blue', 'a', '') and it works (chrome 69.0.3497.100 ) - ben
There was a bug in several recent versions of Chrome but it's fixed in 68, see crbug.com/810581. - wOxxOm
Version 66.0.3359.181 on Ubuntu linux 18.04. Thanks, I'll try on another version. curious to know if this is a bug or desired behaviour though - Halim
thanks for the link @wOxxOm - Halim
@ben - So am I. What made a difference was opening my blasted eyes and reading the format string correctly. :-) (Was kinda hoping you hadn't seen the comment before I deleted it.) - T.J. Crowder