Skip to content

Instantly share code, notes, and snippets.

@zapthedingbat
Created August 19, 2014 12:22
Show Gist options
  • Star 36 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save zapthedingbat/642f71fa58aafc5db691 to your computer and use it in GitHub Desktop.
Save zapthedingbat/642f71fa58aafc5db691 to your computer and use it in GitHub Desktop.
Log every function call to the console
(function() {
var call = Function.prototype.call;
Function.prototype.call = function() {
console.log(this, arguments);
return call.apply(this, arguments);
};
}());
@zhycs
Copy link

zhycs commented Jan 28, 2019

helpful , thanks for share

@jelnur
Copy link

jelnur commented Apr 10, 2020

Sorry for stupid question, but how to use it?

@madhawa-se
Copy link

@jelnur just include the file on the page.or just put the code top of your script file

@jelnur
Copy link

jelnur commented Apr 17, 2020

@madhwa-se thanks I'll give it a try

@edwardyunghk01
Copy link

console.log uses proto.call, which doesnt work at all

@FabianoLothor
Copy link

Doesn't work. :/

(function() {
    function hi() {
    }

    var call = Function.prototype.call;
    Function.prototype.call = function() {
        console.log("hi", this, arguments);
        return call.apply(this, arguments);
    };

    hi();
}());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment