I need a way to track all function calls that work with a particular workspace variable β for example, a sound form that will be transformed using various signal processing functions.
One cumbersome and fragile method is as follows:
>> cfg = [];
>> curr_call = 'data_out = my_function(cfg,data_in);';
>> eval(curr_call);
>> data_out.cfg.history = cat(1,data_out.cfg.history,{curr_call});
Which would be much better:
>> cfg = [];
>> data_out = my_function(cfg,data_in);
>> data_out.cfg.history
'data_out = my_function(cfg,data_in);'
EDIT for clarification: In other words, this variable has a field cfg.historythat keeps track of all the history-supported functions that operated on (ideally with arguments). The history field should be updated no matter where the function calls come from: my example is from the command line above, but calls made from the cell mode or inside the script should also be added to the history. Obviously, I can edit my_function()in the above example so that it can change the history field.
NOTE in response to the discussion below: the motivation for this is that the story βsticksβ to the data in question, rather than talking in a separate log file, which would then need to be somehow packed into the data.
Can this be done?