How can I reset haxe.Log.trace to its default?

Hello. I have a function somewhere in my project’s code that rebinds trace to another function, but I can’t change it for now.
Is there a way I can (temporarily) reset haxe.Log.trace to its default function?

Thank you!

You need to store the default implementation somewhere.

var defaultTrace = haxe.Log.trace;
haxe.Log.trace = myCoolTrace;
//<...do something...>
haxe.Log.trace = defaultTrace;

Hello and thanks for the answer.

I saw this solution in the documentation, but I need to do it without adding code there. Is there nowhere else that this function is stored to? Or maybe something very similar?

Thanks

Can you add code anywhere it would run before the change? In the program’s entry point method?

If not, you could probably use an initialization macro to store a copy of the haxe.Log.trace function expression in another class and then reset to that copy.

As a (probably) last resort, you could make a copy of the haxe.Log class. (say MyCoolLog.hx) and then reset to its trace method. This one bears the risk of your copy getting outdated as the standard library evolves.