Created
August 19, 2015 16:50
-
-
Save bonpixel/33384f60b3974c131ecb to your computer and use it in GitHub Desktop.
console.log with line number
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
console.log('message', 'Line:' + (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; | |
})()[1].getLineNumber()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment