Skip to content

Instantly share code, notes, and snippets.

@MikeRatcliffe
Created October 29, 2022 10:20
Show Gist options
  • Save MikeRatcliffe/c4188f1726cb2115f2bd06bf69b1c23d to your computer and use it in GitHub Desktop.
Save MikeRatcliffe/c4188f1726cb2115f2bd06bf69b1c23d to your computer and use it in GitHub Desktop.
Function Tracing
const _apply = Function.prototype.apply;
const _call = Function.prototype.call;
_apply.apply = _apply;
_call.apply = _apply;
Function.prototype.toString.apply = _apply;
Array.prototype.slice.apply = _apply;
console.trace.apply = _apply;
function log(t, a) {
console.log("Calling",
Function.prototype.toString.apply(t, []),
"with:",
Array.prototype.slice.apply(a, [1]).toString()
);
console.trace.apply(console, []);
}
Function.prototype.call = function () {
log(this, arguments);
_call.apply(this, arguments);
};
Function.prototype.apply = function () {
log(this, arguments);
_apply.apply(this, arguments);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment