I want to wrap every function call with some logging code. Something that would produce output like:
func1(param1, param2)
func2(param1)
func3()
func4(param1, param2)
Ideally, I would like an API of the form:
function globalBefore(func);
function globalAfter(func);
I've googled quite a bit for this, but it seems like there's only aspect-oriented solutions that require you to wrap the specific functions you want to log, or whatever. I want something that applies to every function in the global scope (except itself, obviously).
jquery-aop might do the trick?
Maybe you could have a function to which you pass the function to execute as a parameter:
A simple approach would be something like this
To undo you would need to run the
Notes
This handles only global functions, but you can easily extend it to handle specific objects or methods etc..