I'm trying to know if in JQuery/JS, it's possible to add an global listener when a function or class method called, or event ? this idea is to display the name function / event in the console for knowing the order and witch function / method was called when debug is true.
Exemple, for now i must call the function debug in all function :
var showdebug = true;
function test(){
debug();
test2();
}
function test2(){
debug();
...
}
function debug(){
if(showdebug === true){
console.log("function name called")
}
}
test();
That display in console
test
test2
What I'm would like do, is not add debug() in each function, i'm searching to do var showdebug = true;
if(showdebug === true){
add listener when all function / method called
and this listener call automatically debug()
}
function test(){
test2();
}
function test2(){
...
}
function debug(){
console.log("function name called")
}
test();
So when i called test, this listener called auto the debug function for display in console
test
test2
Thanks for you help.