util: treat format arguments equally, add format string detection by silverwind · Pull Request #23162 · nodejs/node (original) (raw)

I cannot fix above errors without re-introducing the issue that this was meant to fix.

Our current implementation of util.format outputs types other then object and symbol using String() when the first argument is a string. When the first argument is not a string, inspect is used on all arguments, which results in inconsistent output like this:

screenshot 2018-09-30 at 10 43 10

My implementation removes this inconsistency by always formatting arguments the same, regardless of their position in the argument list:

screenshot 2018-09-30 at 10 43 44

I think this is the best compromise we can do and it's worth the breaking change in the console output.

A even better way could be to run all types through util.inspect, but that would mean we'd have to remove string quotes and all strings in console output would become colored, which would probably break a ton of things.