adamschwartz / log

Console.log with style.
https://adamschwartz.co/log
MIT License
3.01k stars 140 forks source link

If at all possible, I would really appreciate having the file / Line # of invocation included #5

Closed noeticpenguin closed 11 years ago

noeticpenguin commented 11 years ago

First off, Adam this is a brilliant piece of kit. Kudos.

I'm putting together a pack of Javascript libraries for Salesforce developers and would really love to include your library. One hitch, however, is the automatic inclusion of the file / line # of the invocation. I suspect that we'll always see log.js:19 on the right, but perhaps the file / line # of the invoking script can be included as a "tag" or something on the left ?

adamschwartz commented 11 years ago

@noeticpenguin, thanks!

We definitely want to add line numbers. However, unfortunately, the nature of wrapping console.log means we'll lose the ability to display the line number on the right.

There are a number of possible solutions we are considering to address this. For example, if we change the exports at the bottom of the script to something like the following:

window.log = console.log.bind(console)
window.log.format = stringToArgs

Then you could call the following and still get line numbers:

log(log.format('this is _bold_'))

If you didn't want the text to be formatted, you could still call:

log('this is _just some text with two underscores around it_')

Of course, having to wrap your string in a log.format is certainly less sexy than we'd like. So we're considering other possible solutions as well.

You can keep track of the progress we make on this by checking out https://github.com/adamschwartz/log/issues/1.

Thanks again for your support. We definitely want to continue to improve log in the weeks to come.

On a related note, there may be some potential changes coming to console.log. We're actively following and participating in the discussions here:

https://code.google.com/p/chromium/issues/detail?id=167911 https://bugs.webkit.org/show_bug.cgi?id=20141

Hope this helps!