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
,
Jul 31
As per comment #0, it seems to be a feature request. Hence, marking it as untriaged for further inputs from Dev team. Thanks...!
,
Aug 13
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 |
|||
Comment 1 by woxxom@gmail.com
, Jul 30