New issue
Advanced search Search tips

Issue 869101 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner:
Closed: Aug 13
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 2
Type: Bug



Sign in to add a comment

Feature Request: Enable multiple arguments when styling console.log statements

Reported by kaycebas...@gmail.com, Jul 30

Issue description

UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36

Steps to reproduce the problem:
1. Run `console.log("%cHello", ", World!", "color:green")`

What is the expected behavior?
The text "Hello, World!" is printed green.

What went wrong?
Style formatting does not work. It requires two arguments, first being the string to output and the second being the styles. This could be more flexible by allowing an arbitrary amount of args, and using the last arg as the styles.

Did this work before? No 

Chrome version: 68.0.3440.75  Channel: stable
OS Version: 
Flash Version: 

source of idea: https://twitter.com/NutonDev/status/1023998882936774656
 
And how would that work if there are also %o %d %s and multiple %c?
Treating color variables differently would make it very inconsistent.
Cc: phanindra.mandapaka@chromium.org
Labels: Triaged-ET Target-70 M-70 FoundIn-70 OS-Mac OS-Windows
Status: Untriaged (was: Unconfirmed)
As per comment #0, it seems to be a feature request. Hence, marking it as untriaged for further inputs from Dev team.

Thanks...!
Cc: -phanindra.mandapaka@chromium.org
Owner: l...@chromium.org
Status: WontFix (was: Untriaged)
Thanks for the request.  Intuitively, the example makes sense, but I also agree with the concerns about mentioned in c#1.  Changing today's logic could also break 3rd party libraries.

I think the root issue is that there are 2 competing mental models:
- One expects adding a new argument to console.log to just print the new value (with the same style):
`console.log('x is', x, ', y is', y)`

- One expects substitution arguments to always come immediately after the template:
`console.log('x is %s, y is %s', x, y)`

The '%c' style is treated as a substitution, but this interferes with the first model.  The best place to discuss this is likely in the Console Standards repo [1].  Most browsers' Consoles treat substitutions the same way today, and deciding on new behavior would benefit from cross-browser discussions.

[1] https://github.com/whatwg/console/issues

Sign in to add a comment