Skip to content

Instantly share code, notes, and snippets.

@fabiosantoscode
Forked from JosePedroDias/README.md
Last active August 29, 2015 14:10
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 fabiosantoscode/efcb6aa5626035717851 to your computer and use it in GitHub Desktop.
Save fabiosantoscode/efcb6aa5626035717851 to your computer and use it in GitHub Desktop.

if you want to log the call parameters for function xyz, add this is the first line of xyz:

function xyz(p1, p2) {
    debugFunctionCall('xyz', arguments);
    ...
}

then if you call

xyz(2, "stuff", {a:2});

it prints

(xyz 2 "stuff" {"a":2})
function debugFunctionCall(functionName, args) {
var o = [];
o.push('(');
o.push(functionName);
for (var i = 0, I = args.length; i < I; ++i) {
o.push( JSON.stringify(args[i]) );
o.push(' ');
}
o.pop();
o.push(')');
console.log( o.join('') );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment