At try.haxe.org is there any way to not get that data-stamp info in the output? I’d like to be able to copy/paste text in that output window without the data-stamps.
Hej,
Do you mean the traces ?
In this case, just open your debug window and you’ll see the traces there without any data stamp.
Ok. Well, this is interesting. The following gives me clean (no filename and line numbers) output to the JS console:
trace("hi");
for (i in 1...5) { trace(i); }
trace("bye");
but this gets me filename + line numbers:
trace("hi");
for (i in 1...5) { trace("it's ", i); }
trace("bye");
Haxe’s trace
is not really analogous to JavaScript’s console.log
.
It doesn’t take in a rest list of arguments and concatenate them like JavaScript; Haxe’s trace
takes in haxe.PosInfos for the second argument; and populating it will cause position info to be included in the resultant trace. Read more here
Ah. Thanks. Using
haxe.Log.trace(msg, null)
throughout causes it to omit the prefix position information.
Yes, you can also override the defaut haxe trace function once, and then use trace
like this :
haxe.Log.trace = function( o : Dynamic, ?infos : haxe.PosInfos ){
var rest = infos.customParams != null ? infos.customParams.join(","): "";
js.Browser.console.log( o + rest );
}
trace("hi");
for (i in 1...5) { trace("it's ", i); }
trace("bye");
Ok, looks like I can also just directly use
js.Browser.console.log("foo", whatev, 42);