Created
January 11, 2013 12:10
-
-
Save pirhoo/4510257 to your computer and use it in GitHub Desktop.
Unfolds objects completely with log, info and error methods of console.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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