Created
January 28, 2015 14:04
-
-
Save nicoptere/7141b01770ff9e98f18c to your computer and use it in GitHub Desktop.
tries to log the function caller
This file contains hidden or 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
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