Reputation: 56958
I'm trying to get an understanding of why I would use Ember.Logger
instead of just using console.log
directly. The problem is, no matter where I log from (from any file), the output shows the log as emanating from:
ember.js?body=1:15359
Whereas, if I use console.log, I get a more helpful log location, including the file that logged and where in the file:
application.js?body=1:9
Is there a way to use Ember.Logger that would show the location and information? The docs indicate that one should "[o]verride this to provide more robust logging functionality." Should I just assume that this is supposed to be for overriding and making something really fancy and not just for basic logs to the console?
Upvotes: 0
Views: 504
Reputation: 37369
To answer your question directly, no, I don't think there is a way to have the Ember logger report the correct line numbers. Logging to the console is just a commonly implemented API, it's not a Javascript standard. Because of this, the browser automatically determines where a log statement came from and makes it pretty much impossible to wrap a layer of indirection around it. There might be some clever ticks out there, but none that I know of.
But more importantly, I don't think Ember's logger is really meant for third party consumption. It's mostly used internally by Ember, so the main reason you would override it is to redirect Ember's logging to a different location. In my opinion, it seems like a fairly poor way to handle your own application logging.
Upvotes: 1