Skip to content

Instantly share code, notes, and snippets.

@nicoptere
Created January 28, 2015 14:04
Show Gist options
  • Save nicoptere/7141b01770ff9e98f18c to your computer and use it in GitHub Desktop.
Save nicoptere/7141b01770ff9e98f18c to your computer and use it in GitHub Desktop.
tries to log the function caller
var console = (window.console = window.console || {});
var original = console[ 'log' ];
console[ "log" ] = function()
{
var args = Array.prototype.slice.apply( arguments );
original.apply( console, args );
try
{
throw new Error();
}
catch(e)
{
//quick & dirty parse the stack trace, gets last item
original.call( console, "link to function", e.stack.match(/at .*$/g)[0].replace("at ", ""));
}
};
console.log( "abc" );
console.log( "hey" );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment