Skip to content

Instantly share code, notes, and snippets.

@pirhoo
Created January 11, 2013 12:10
Show Gist options
  • Save pirhoo/4510257 to your computer and use it in GitHub Desktop.
Save pirhoo/4510257 to your computer and use it in GitHub Desktop.
Unfolds objects completely with log, info and error methods of console.
(function(c){
// Do not extend the console twice
if(c.__elg__){return;}
var util = require('util');
// Maps this three console's methods
['log', 'info', 'error'].forEach(function(f){
var _= c[f];
c[f] = function(){
var args = arguments;
for(var a in args) {
// Only apply the inspect to objects
if(typeof args[i] == "object") {
args[i] = util.inspect(args[i], false, null);
}
}
return _.apply(c, args);
};
});
c.__elg__ = true;
})(console);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment