#How to get the nice Deno console.log format into a string?

1 messages · Page 1 of 1 (latest)

distant sandal
#

When I do a console.log on an instantiated class object, I get a beautiful format in the terminal, thanks to Deno. How would I get that same nice Deno format into a string? When I do obj.toString(), I just get the standard Javascript [object Object].

rigid oak
#

I'm not sure if that formatting is exposed to us. Maybe it's internal to Deno

What you can do is JSON.stringify(obj). Not the same output as console.log, but better than .toString()

tawdry parcel
#

Try Deno.inspect(myObj) which returns a string in the same format as console.log(myObj)

rigid oak
#

Oh I didn't know that one. Nice

distant sandal