Visualize console.log empty string output

NEW
Unassigned

Status

P3
normal
a year ago
5 months ago

People

(Reporter: shimscharf, Unassigned)

Tracking

54 Branch
Bug Flags:
qe-verify +

Firefox Tracking Flags

(firefox57 wontfix)

Details

(Reporter)

Description

a year ago
User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0
Build ID: 20170608105825

Steps to reproduce:

- open developer tools
- go to console
- type:

console.log("")


Actual results:

output:
blank line


Expected results:

""

output should be empty string within double quotations marks.
This would be consistent with output from console.log {a:""}
(Reporter)

Comment 1

a year ago
This could be a huge problem if the following occurs with debugging:

console.log("", true)

Actual output:
true

Expected output:
"", true
Component: Untriaged → Developer Tools: Console

Comment 2

a year ago
Thanks for reporting shimscharf.
It's true that this is a bit confusing.
I think the idea to omit the quotes in the logged messages was to make them easier to read (`console.log("Hello", "world")` would be not that nice output as `"Hello" "world"`).
We might want to show those quotes when we have an empty string, since it would help the user to see if there's an issue with a variable for example.

The expected output would then be `"" true` (we don't insert comma between logged arguments).

What do you think of this Brian ? Is there something I miss ?
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: qe-verify+
Flags: needinfo?(bgrinstead)
Priority: -- → P3
(Reporter)

Comment 3

a year ago
Hi,

Yes, that is correct, it should only apply to empty strings to display "" in red to match console string output.

Same as it does in console.log ({a:""}), and console.log([""])

The commas used to be there in old versions of Firebug -> sorry, just a habit of mine over the years.

Cheers,
Simon

Comment 4

a year ago
The work is likely to happen in the Reps repository on Github : https://github.com/devtools-html/devtools-core/issues/490
(In reply to Nicolas Chevobbe [:nchevobbe] from comment #2)
> Thanks for reporting shimscharf.
> It's true that this is a bit confusing.
> I think the idea to omit the quotes in the logged messages was to make them
> easier to read (`console.log("Hello", "world")` would be not that nice
> output as `"Hello" "world"`).
> We might want to show those quotes when we have an empty string, since it
> would help the user to see if there's an issue with a variable for example.
> 
> The expected output would then be `"" true` (we don't insert comma between
> logged arguments).
> 
> What do you think of this Brian ? Is there something I miss ?

We've discussed this further in https://github.com/devtools-html/devtools-core/issues/490 and https://github.com/devtools-html/devtools-core/pull/491#issuecomment-314853337
Flags: needinfo?(bgrinstead)
Summary: console.log empty string output → Visualize console.log empty string output
(In reply to shimscharf from comment #1)
> This could be a huge problem if the following occurs with debugging:
> 
> console.log("", true)
> 
> Actual output:
> true
> 
> Expected output:
> "", true

In this case we should at least follow the Node / Chrome convention and render:

 true

instead of:

true

It's subtle, but there is an implied space between log arguments which is something we are missing.
status-firefox57: --- → wontfix

Updated

5 months ago
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.