I need to distinguish "0"
from 0
in Firebug console.log
output.
If you type console.log("0")
into Firebug console, you'll get 0
, same as if you'd typed console.log(0)
, but I need it to be "0"
.
In other words, expected output:
console.log("0")
> "0"
console.log(0)
> 0
Actual:
console.log("0")
> 0
console.log(0)
> 0
What is the best solution to this problem?
I've found some workarounds like console.log("%o", "0")
or console.log(["0"])
, but they are too clumsy and obtrusive to use them everywhere.
I've also tried debug
and info
without success.
By the way, Chrome console gets it right, but I'm not ready to move to Chrome yet.
I'm thinking about writing some wrapper around console object. I'm not sure how to do it right but I'll try it if there is no other solution.
So, the only solution seems to be that you need make some wrapper that looks like this (based on @wsanville's answer):
var log_orig = console.log;
// No need to check for type, just use %o for everything
// Also, it gets messier for multiple arguments
console.log = function(s) { log_orig('%o', s); }
But then you get the problem with line numbers, as described in How to access line numbers when wrapping Firebug (or similar) Console api
I guess I should file a firebug bug or something, because this can be really critical in some situations.