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('') ); | |
} |