Conversation
| // access to the provider. | ||
| segment.debug = function () { | ||
| return Segment.prototype.debug.apply(provider, arguments); | ||
| }; |
There was a problem hiding this comment.
@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 :)
I prepared a solution that:
$log.logby default (which makes it backwards compatible)debugLevelconfig)Some validation is also provided.