Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[js std] trace improvements #5639

Closed
clemos opened this issue Sep 6, 2016 · 12 comments
Closed

[js std] trace improvements #5639

clemos opened this issue Sep 6, 2016 · 12 comments
Assignees
Labels
enhancement platform-javascript Everything related to JS / JavaScript

Comments

@clemos
Copy link
Contributor

clemos commented Sep 6, 2016

in https://github.com/HaxeFoundation/haxe/blob/development/std/js/Boot.hx#L47-L65

  • the feature that checks / logs to a div#haxe:trace should be moved to a legacy class, and included only if -D legacy-trace or similar
  • __string_rec should be used only in this case (ie: when the console is not used)
  • in the other case, when logging to the console, we should pass v and i.customParams as-is, and let the JS environment deal with displaying the data

If you want, I can make a PR with that improvement.

@nadako nadako added enhancement platform-javascript Everything related to JS / JavaScript labels Sep 6, 2016
@nadako
Copy link
Member

nadako commented Sep 6, 2016

I agree about haxe:trace/jsfl stuff, that looks out of place, but I'm not sure about __string_rec. On one hand, passing objects to console will enable nice features of browser consoles such as object inspection, but on the other - it'll print some stuff like enums in an ugly way (or am I wrong and it'll use the toString method?)

@clemos
Copy link
Contributor Author

clemos commented Sep 7, 2016

IMHO it's fine to output the raw / native value "by default", and have something very light in haxe.Boot. Enums are usually understandable, even this way (and inspectable).
Then we can provide other logger methods with more features (nicer enums, ...), that could be activated either with a compiler flag (-debug ?), or with using standard override haxe.Log.trace = haxe.ConsoleLogger.factory({ prettyEnums:true}) haxe.DomLogger.factory({selector:"#haxe:trace"}) or something.

@nadako
Copy link
Member

nadako commented Sep 7, 2016

That makes sense to me, but I don't know who's the one to make the call about it. @ncannasse ?

@clemos
Copy link
Contributor Author

clemos commented Sep 7, 2016

While we're at it, I was wondering if it would be feasible to inline the call to console.log to benefit from sourcemaps in Developer Tools.

@nadako
Copy link
Member

nadako commented Sep 7, 2016

Not sure if that's possible, since haxe.Log.trace is a dynamic method and hence is not inlineable.

@nadako
Copy link
Member

nadako commented Sep 9, 2016

Actually, I think we could just generate console.log calls even if there's more than one argument to trace, unless haxe.Log.trace is directly used, hmm...

@Simn Simn modified the milestone: 4.0 Jan 9, 2017
@nadako nadako self-assigned this Apr 3, 2017
@nadako
Copy link
Member

nadako commented Apr 3, 2017

I'm gonna proceed cleaning this up, starting by removing haxe:trace and jsfl stuff.

nadako added a commit that referenced this issue Apr 25, 2017
we might want to provide a legacy trace function in hx3compat
@Simn Simn removed this from the Release 4.0 milestone Apr 17, 2018
@Simn
Copy link
Member

Simn commented Apr 18, 2018

Can this be closed?

@Simn Simn added this to the Backlog milestone Apr 18, 2018
@Simn
Copy link
Member

Simn commented Jun 5, 2018

Let me know if there's something left to do here.

@Simn Simn closed this as completed Jun 5, 2018
@nadako
Copy link
Member

nadako commented Jun 5, 2018

The idea was to try generating console.log("Main.hx:42", a, b, c) for trace(a, b, c) instead of full-fledged haxe.Log.trace(...), but that's not too important I think.

@back2dos
Copy link
Member

back2dos commented Jun 5, 2018

Ping @mastef. IIRC he had very strong feelings about this ^^

@mastef
Copy link
Contributor

mastef commented Jun 5, 2018

I think it would be fantastic if trace would natively pass through to console.log - including the line numbers / source map information.

Currently it's a pity that trace transforms everything to strings before pushing it to the browser console, losing all the nice debugging and inspection features the browser natively provides for objects. And replicating the magic trace behaviour with macros proved quite an interesting challenge, as you need rest arguments capability + trailing pos. It's possible, but tricky to get right from what I recall.

So it would be great to have this functionality natively instead. ( And if somebody really requires string literals output to console, then a switch could be provided. )

I remember there was a macro version somewhere of this - and one approach made it into this gist. And then there is also this fine library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement platform-javascript Everything related to JS / JavaScript
Projects
None yet
Development

No branches or pull requests

5 participants