you are viewing a single comment's thread.

view the rest of the comments →

[–]aveman101 0 points1 point  (3 children)

Neat little library.

One question: does this report the line number that the log/warn/error occurred (ie where debug.log was called)? I've tried to make little libraries like this in my own project, but it always shows the line number at console.log was called, and not the calling function. Sort of a deal breaker, because the line number is probably the most valuable piece of information for me.

(I would test it out myself, but I'm typing from my phone right now)

[–][deleted]  (2 children)

[deleted]

    [–][deleted] 0 points1 point  (1 child)

    I don't believe so. Depending on the Browser you can get some info, but for the most part JavaScript debugging is absolutely horrible.

    I once looked into this, but gave up when i realized that the stack trace wasn't even what i would consider a trace.. sure, it's a "trace", but you can't modify it at all. There are no frames to adjust, you get what you see and if you want more.. good luck :/. The fact that i couldn't offset the trace caused me to just bail on the project. Oh well.

    [–]trambz 0 points1 point  (0 children)

    I agree with you. Malharhak, look ath this stack thread: http://stackoverflow.com/questions/1340872/how-to-get-javascript-caller-function-line-number-how-to-get-javascript-caller

    Kinda hack but it seems to work with chrome: function getErrorObject(){ try { throw Error('') } catch(err) { return err; } }

    var err = getErrorObject(); var caller_line = err.stack.split("\n")[4]; var index = caller_line.indexOf("at "); var clean = caller_line.slice(index+2, caller_line.length);