Joined November 2014
·

Mike Stanley

Cambridge, MA
·
·

The default formatting for some objects using console.log is not helpful.
For example, I'm using Emberjs and console.log(Ember) shows (in Chrome/Safari):

Object {__loader: Object, imports: Window, exports: Window, lookup: Window, ...}

where it would be much more helpful to see:

class Ember

It appears that "inspect" method is used for formatting objects in console.log, not toString.
Does anyone know how to override the default output from calling inspect?

My goal is to output short, customized-per-object, useful descriptions. For example, in Ember, I want to see:

"an App.Post id:5" or "App.PostController" or "a App.PostController 32"

so I know if object is a class or instance, whether it has a path from the global window object, whether it has an id, etc. It's much more difficult to debug when you can't easily get this information from an object.

Achievements
1 Karma
0 Total ProTip Views