Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Common output format #21

Closed
Nitrogenycs opened this Issue · 19 comments
@Nitrogenycs

Right now the different browsers return the individual entries in a different format, e.g. chrome it looks like

0: "Object.run (http://localhost:8080/resources/app.core.resources/stacktrace.js:75:14)"
1: "printStackTrace (http://localhost:8080/resources/app.core.resources/stacktrace.js:59:20)"
2: "Object.log (http://localhost:8080/resources/app.log.resources/log.js:96:13)"
3: "http://localhost:8080/resources/app.log.resources/log.js:128:7"

While the same code in firefox looks like

0 "{anonymous}()@http://localhost:8080/resources/app.log.resources/stacktrace.js:70"    
1 "{anonymous}(null)@http://localhost:8080/resources/app.log.resources/stacktrace.js:68"
2 "printStackTrace()@http://localhost:8080/resources/app.log.resources/stacktrace.js:59"
3 "{anonymous}("Logging started")@http://localhost:8080/resources/app.log.resources/log.js:96"  
4 "@http://localhost:8080/resources/app.log.resources/log.js:128"

Opera and other browser look yet different.

It might be useful if stacktrace.js entries would be full objects with members "function", "url", "line", "column". So one line of the above output would look like

entry = { function : 'printStackTrace', url : 'http://localhost:8080/resources/app.log.resources/log.js', line : 96, column: 12 }

@eriwen
Owner

Agreed that more structure would be useful. I will schedule this for 0.5. Thanks for your feedback

@eriwen eriwen was assigned
@eriwen
Owner

I'm going to move away from String based stacktraces (though I'll keep them around for those that use them) to Object output instead.

@JamesMGreene

Subscribe

@champo

Are there any plans to implement this?

@eriwen
Owner

@champo Yes, I'm have been working (albeit slowly) on a rewrite of stacktrace.js that will include this.

@joshuap

:+1: this would be sweet :)

@alexstrat

What's the state of this ?

@kmontag

+1 for this - @eriwen, any chance you could post your rewrite (however far along it is) in a branch so we can submit PRs?

@eriwen
Owner

Sorry guys for being lame and slow on this. The next version of stacktrace.js is going to introduce a more modular architecture, with one part being an Error normalizer. I have pushed a really rough start to the api-spike branch (https://github.com/eriwen/javascript-stacktrace/tree/api-spike) which does not include other modules of the new impl as they are not rough-ready yet.

Please look at error-parser.js and the tests and give feedback or submit PRs to it if you like.

Cheers,
Eric

@victor-homyakov

Syntax looks a bit strange. De facto when function name starts from capital letter it means constructor, so when I see function StackEntry I'll probably try to use it like var se = new StackEntry() rather than var se = StackEntry(), but in order to work as constructor it should look like

function StackEntry(functionName, srcUrl, lineNumber, charNumber) {
    this.fn = functionName;
    this.args = [];
    this.src = srcUrl;
    this.line = lineNumber;
    this.char = charNumber;
}

The same applies to ErrorInfo and especially ErrorParser (which is exposed as a global object).

@eriwen
Owner

@victor-homyakov Yep. How absent-minded of me. I've also added an idea I had for utilizing Error.prepareStackTrace for V8.

@fresheneesz

This still isn't in? Whats the status of this? Looks like its been 3 years in the making..

@fresheneesz

@victor-homyakov I quickly cobbled together a module that creates a list of standard output objects, instead of textual stack traces, because I couldn't wait for this. Here it is: https://github.com/fresheneesz/stackinfo . Would love help testing it, or advise as to how to go about doing that effectively.

@niemyjski

We'd really like to use this module but it hasn't seen any updates in a long while and I haven't had time to contribute :..

@bountin

Any updates on this issue?

@eriwen
Owner

@bountin Being worked on for v1.0 - http://git.io/stack-parser

@fresheneesz

@bountin @eriwen Does stackinfo not do exactly what you're looking for? I'm a little confused why you're doing work I've already done. I would be happy to merge my work into that project if you want to take it further than I have.

@eriwen
Owner

@fresheneesz Sorry, despite your issue on the stack-parser I forgot about stackinfo until a couple days ago. There are a couple things I want to talk with you about regarding stackinfo over email. Could you either provide an email addy for me or email me first me@eriwen.com and we can see how we might work together toward a common goal

@eriwen eriwen modified the milestone: 1.0, 0.9
@eriwen
Owner

New common format for 1.0: https://github.com/stacktracejs/stackframe

@eriwen eriwen closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.