Skip to content

Instantly share code, notes, and snippets.

@bonpixel
Created August 19, 2015 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bonpixel/33384f60b3974c131ecb to your computer and use it in GitHub Desktop.
Save bonpixel/33384f60b3974c131ecb to your computer and use it in GitHub Desktop.
console.log with line number
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