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

**URL:** https://community.haxe.org/t/how-can-i-reset-haxe-log-trace-to-its-default/2232
**Category:** Haxe
**Created:** [January 25, 2020, 11:28pm UTC](https://community.haxe.org/t/how-can-i-reset-haxe-log-trace-to-its-default/2232 "2020-01-25T23:28:51Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![daverave1212](https://community.haxe.org/user_avatar/community.haxe.org/daverave1212/32/1124_2.png) [@daverave1212](https://community.haxe.org/u/daverave1212)
#### Post date: [January 25, 2020, 11:28pm UTC](https://community.haxe.org/t/how-can-i-reset-haxe-log-trace-to-its-default/2232/1 "2020-01-25T23:28:51Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![RealyUniqueName](https://community.haxe.org/user_avatar/community.haxe.org/realyuniquename/32/10_2.png) [@RealyUniqueName](https://community.haxe.org/u/RealyUniqueName)
#### Post date: [January 25, 2020, 11:31pm UTC](https://community.haxe.org/t/how-can-i-reset-haxe-log-trace-to-its-default/2232/2 "2020-01-25T23:31:38Z")

</div>

You need to store the default implementation somewhere.

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

```

---

<div class="post-metadata">

### Author: ![daverave1212](https://community.haxe.org/user_avatar/community.haxe.org/daverave1212/32/1124_2.png) [@daverave1212](https://community.haxe.org/u/daverave1212)
#### Post date: [January 26, 2020, 12:43am UTC](https://community.haxe.org/t/how-can-i-reset-haxe-log-trace-to-its-default/2232/3 "2020-01-26T00:43:09Z")

</div>

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

---

<div class="post-metadata">

### Author: ![vlado](https://community.haxe.org/user_avatar/community.haxe.org/vlado/32/1074_2.png) [@vlado](https://community.haxe.org/u/vlado)
#### Post date: [January 26, 2020, 8:07am UTC](https://community.haxe.org/t/how-can-i-reset-haxe-log-trace-to-its-default/2232/4 "2020-01-26T08:07:28Z")

</div>

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.
