ember-debug-logger icon indicating copy to clipboard operation
ember-debug-logger copied to clipboard

Integration with `Ember.Logger`?

Open rmharrison opened this issue 8 years ago • 2 comments

Q: How difficult would it be to use Ember.Logger.debug instead of this.debug? Have not overwritten Ember core components before, and was hoping for a bit of guidance within the context of ember-debug-logger, possibly for a PR.

My issue with this.debug is the difficulty of refactoring/adding additional functionality beyond the scope of ember-debug-logger. For example, while console logging is great for now, I know I'll want to injest JSON-formatted log files, either to a 1st-party logging end-point I create or a 3rd-party service (AWS CloudWatch, Airbrake, Rollbar, etc.)

If this.debug were wrapped in Ember.Logger.debug, I could include these additional log streams at Ember.Logger.debug without touching ember-debug-logger.

There is precedent in the community. For example, ember-cli-rollbar rollbar.critical(msg) <--> Ember.Logger.error(msg), see: https://github.com/davewasmer/ember-cli-rollbar/blob/master/app/initializers/rollbar.js#L8

rmharrison avatar Nov 20 '17 19:11 rmharrison

The consensus seems to be that Ember.Logger isn't really necessary anymore, since it's basically just a polyfill for console.log. It intentionally didn't get assigned an import path in the new modules API.

The debug library itself supports custom output streams and custom formatters, though, so you could do something like this:

window.debug.log = (...params) => {
  // multiplex to various locations, including Ember.Logger.debug if you like
};

dfreeman avatar Nov 20 '17 19:11 dfreeman

@dfreeman how could I set this to this.logger.debug instead of this.debug? otherwise i'd need to update a huge amount of code which isn't ideal

erichaus avatar Jan 06 '18 21:01 erichaus