How to add time for global trace?

current trace

I want to add extra time info to global

xxx.hx:309 [2019-10-1-20:12]?

See haxe/Log.hx.
Declaration of haxe.Log.trace is prefixed with static dynamic function, that dynamic keyword in the context of a function means you can redefine this function implementation from anywhere.
Here is an example:

var oldTrace = haxe.Log.trace;
haxe.Log.trace = function(v:Dynamic, ?pos: haxe.PosInfos) {
    oldTrace("[" + + "] " + Std.string(v), pos);

// from anywhere

The var oldTrace holding the old implementation seems temporary here, but its value is permanently kept in the closure, so once executed it will work from anywhere, so you don’t have to care about the local oldTrace variable anymore.

1 Like

thanks @emugel,it’s work