Skip to content

Conversation

@jrencz
Copy link

@jrencz jrencz commented Sep 26, 2016

I prepared a solution that:

  • uses $log.log by default (which makes it backwards compatible)
  • allows changing the logging level of the debug function (using debugLevel config)
  • allows setting entire logger object/function/service (please take a look at the test suite for more details)

Some validation is also provided.

@coveralls
Copy link

Coverage Status

Coverage decreased (-2.6%) to 93.678% when pulling b0bd3e9 on functionite:configurable-logger into e10fb3b on aleross:master.

// access to the provider.
segment.debug = function () {
return Segment.prototype.debug.apply(provider, arguments);
};
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aleross I had some problem with the prototype chain. For testing purposes (only?) segment service has debug function exposed. It did work but only if it wasn't referring properties declared only on the SegmentProvider (logger is only defined there). All internal uses of this.debug work as expected because dynamic context in all those cases is SegmentProvider. Calling segment.debug from outside made the context a segment service which has no logger (provider does).

I wanted not to expose the logger on segment (to prevent potential collisions with analytics.js api in the future) so I decided to shadow the method directly on the exposed object.

If you know of a better solution then please describe it. I'll be more than happy to learn something here :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants