Skip to content

Instantly share code, notes, and snippets.

@lukluk
Created April 7, 2016 10:28
Show Gist options
  • Save lukluk/c371328b38374dce7b130c2d4c8150f9 to your computer and use it in GitHub Desktop.
Save lukluk/c371328b38374dce7b130c2d4c8150f9 to your computer and use it in GitHub Desktop.
Complate Console.log
Object.defineProperty(global, '__stack', {
get: function(){
var orig = Error.prepareStackTrace;
Error.prepareStackTrace = function(_, stack){ return stack; };
var err = new Error;
Error.captureStackTrace(err, arguments.callee);
var stack = err.stack;
Error.prepareStackTrace = orig;
return stack;
}
});
Object.defineProperty(global, '__line', {
get: function(){
return __stack[1].getLineNumber();
}
});
function fullLog(obj){
console.log((new Date()),__filename,'LINE ',__line,obj)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment