I am creating a log to keep track of the functions that are called. One specific function I am using is
record_activity( function_name );
I find it tedious to manually add this at the beginning of every function I want to monitor. Currently, my functions are structured like:
Object.Key.Func = function() { ... }
I have come up with a solution which seems to be working, but I am unsure about its implications:
function sub ( variable, func ) {
var temp_func = function ( args ) {
record_activity( variable );
return func.apply(this,arguments);
}
eval( variable + ' = ' + temp_func );
}
sub( 'Object.Key.Func', function (name) { alert('hi ' + name) } );
Object.Key.Func('test');
If there is a method to achieve this without using eval, I would greatly appreciate it.
Thanks