问题
I want to add to all functions in module logger. I want to log "start" time of the function and "end" time. So that's way I can get performance time of every function (sync functions).
But I can't get how to make it work.. =( I don't want to rewrite functions in some dynamic way - I want to debug them in the future..So need to keep original code - I need to find some way to wrap every function...
Lets take a look some example:
module.exports = {
someVar: "12345string",
operation1: function(){
alert("operation1");
},
operation2: function(){
alert("operation2");
}
};
Once module's function executed, we need to run some "pre" and "post" execution script...
How can I do this? Help please... I have a lot of modules and functions... =(
回答1:
OK! So I used meld package and that's works great!
As Jim Garrison said in the comment - every AOP package/lib can help to solve that problem.
I found meld as very simple & clear.
来源:https://stackoverflow.com/questions/38950120/catch-listen-to-functions-execution