I have this function on an object that I need to trace REALLY BADLY, along with the parent caller of the invocation and arguments passed to the caller.
This well works until minified:
var foo = {
FunctionToBeLogged: function GiveMeAName() {
console.log('> %s called from %s - args: %o',
arguments.callee.name,
arguments.callee.caller.name,
arguments.callee.caller.arguments);
}
}
var bar = {
A: function A(something) {
foo.FunctionToBeLogged('nothing', 12, true);
},
B: function B(whatever, doesntMatter) {
foo.FunctionToBeLogged('nothing', 12, true);
}
}
bar.A(1.2, 'Fred', { }); // > GiveMeAName called from A - args: [1.2, "Fred", Object]
bar.B('Barney', 42, false); // > GiveMeAName called from B - args: ["Barney", 42, false]
Minification gets rid of the these names and my output becomes:
bar.A(1.2, 'Fred', { }); // > called from - args: [1.2, "Fred", Object]
bar.B('Barney', 42, false); // > called from - args: ["Barney", 42, false]
I really don't want to go and create function declarations and assignments because I have TONS of them (I inherited this code with 7,564... and I can easily run some regex sub to name the function expressions.)
What can I do to prevent the minifier to get rid of my these function names?