Angular.js: $log.anything() doesn't show accurate line number

Created on 15 Jun 2013  Â·  16Comments  Â·  Source: angular/angular.js

It's really frustrating trying to track down where a specific $log.log() was executed from because the console only shows the line in the AngularJS lib where the function was defined.

Is there any way the context can be adjusted to more accurately convey where the function is being used?

Most helpful comment

FWIW, Chrome now supports this via script blackboxing – https://developer.chrome.com/devtools/docs/blackboxing

All 16 comments

As part of our effort to clean out old issues, this issue is being automatically closed since it has been inactivite for over two months.

Please try the newest versions of Angular (1.0.8 and 1.2.0-rc.1), and if the issue persists, comment below so we can discuss it.

Thanks!

it's still there at the lastest version, plz open it again

This can be worked around in some browsers (Chrome for sure) by setting something like $log.log = console.log.bind(console). But it means that the current formatError() functionality will not be supported in this case, which is probably a good thing since Chrome displays Error objects much much better than formatError(). If PR is welcomed, I'll take this.

$log.log = console.log.bind(console) can't output the right line.

It can. In Chrome it works great. Try it yourself before you use such statements.

http://plnkr.co/edit/yST55SstR5pqD4LZLAeO?p=preview
Take a look in the console of this plunk ('good' is printed with correct line while 'bad' is printed with line inside the log function.

so, that is a solution to not use $log.
yes, I'm using console.log, when I found $log and want to use it,
then found it lost the line info, so it's useless currently for me.

That's a suggestion of how $log can be fixed.

Furthermore, $log.log = console.log.bind(console) is not compatible with IE9, so it is a workaround just for the development env.

Damn, thats a big no no to using $log... Ditching the console postponed again.

tumblr_md0ob9rvqo1rdtgc0o1_400

FWIW, Chrome now supports this via script blackboxing – https://developer.chrome.com/devtools/docs/blackboxing

@btford Nice, this is a good fix. I just blackbox the angular.js script and I'm now able to easily know they the traces are written ! Thanks

@btfod thank you! I would never have noticed that feature on my own.

@btford great Idea! thanks!

@btford This is fantastic!

Was this page helpful?
0 / 5 - 0 ratings