How to fix trampled 'this' keyword in service function?


#1

I have a service that overrides the default Ember.Logger to provide my own logging. I’ve discovered that ember logs errors via the function.prototype.apply(this,args) method. This tramples the ‘this’ keyword making it impossible for me to do anything in my service. Is there any way to fix this?

export default Ember.Service.extend({

    LOG_LEVEL_ERROR: 8,

    error: function(){
        this._performLogging(this.LOG_LEVEL_ERROR, arguments);
    },

   _performLogging: function(level, args){
         // my internal logging function
   }
});

I can’t call my inner function, or access parameters, or use this.get()…