background preloader

Javascript

Facebook Twitter

Where is that console.log? 23 May Did you ever have phantom console.log – or more specifically you’ve no idea where it was happening? I have. This tiny bit of code will help you identify where the logging is being called from. The nice thing is it works in the browser and in node. Honourable mention: @garychambers108′s node.js better logging – I’ve been wanting to do something about my rogue consoles and Gary’s article kicked me in to action. ['log', 'warn'].forEach(function(method) { var old = console[method]; console[method] = function() { var stack = (new Error()).stack.split(/\n/); // Chrome includes a single "Error" line, FF doesn't. if (stack[0].indexOf('Error') === 0) { stack = stack.slice(1); } var args = [].slice.apply(arguments).concat([stack[1].trim()]); return old.apply(console, args); };}); If you include this as high as possible in your code base, all subsequent console.log (or warn) calls will include the line the call was made from: Here’s a simplified demo: Simple.

Velocity.js. Isotope. jQuery. Rainbow - Javascript Code Syntax Highlighting. WebGL Fundamentals.