Skip to content

Instantly share code, notes, and snippets.

@joshleaves
Created May 15, 2013 15:00
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 joshleaves/5584637 to your computer and use it in GitHub Desktop.
Save joshleaves/5584637 to your computer and use it in GitHub Desktop.
var d = 0;
var stack = [];
var LOG = console.log;
Function.prototype.callMe = Function.prototype.call;
Function.prototype.call = function () {
var depth = '';
for (var i = 0; i < d; ++i) { depth = depth + ' '; };
++d;
LOG('>>' + arguments.callee.caller.name);
stack.push(depth + '>> ' + arguments.callee.caller.name);
var result = Function.prototype.callMe.apply(this, arguments);
stack.push(depth + '<< ' + arguments.callee.caller.name);
--d;
return result;
};
stack = [ 'RESTART' ];
console.log('foobar');
stack.push('PAUSE');
console.log('barfoo');
stack.push('ENDLOG');
Function.prototype.call = Function.prototype.callMe;
console.dir(stack);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment