Skip to content

Instantly share code, notes, and snippets.

@IUnknown68
Last active December 31, 2015 01:29
Show Gist options
  • Save IUnknown68/7914565 to your computer and use it in GitHub Desktop.
Save IUnknown68/7914565 to your computer and use it in GitHub Desktop.
Logs all calls on a DOM window (or any other object) to the console by replacing the functions with a wrapper. NOTE: This does not deal with errors, it is just for debugging purposes.
var target = window;
for (var i in target) {
if ("function" != typeof target[i]) continue;
target[i] = (function(name, fn) {
return function() {
console.log("" + name + " called");
return fn.apply(target, arguments);
}
})(i, target[i]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment