How to disable deprecation warnings in Ember.js?

前端 未结 6 1334
心在旅途
心在旅途 2021-01-08 01:09

I\'ve written up an application that uses Ember Data. It\'s passing all it\'s tests and running as expected, however, something is causing a repeated deprecation warning to

6条回答
  •  独厮守ぢ
    2021-01-08 02:10

    My suggestion here, so you won't completely miss the deprecation warnings - they're there for a reason, right?

    These are simplified versions of what deprecate would do, but logging to DEBUG (so you can filter them out easily) and without the stacktrace (for simplicity). They'll also not show repeated messages:

    CoffeeScript:

    Ember.deprecate = (->
      already_shown = []
      (msg, test, opt)->
        return false if test
        if already_shown.indexOf(msg) == -1
          warning = "DEPRECATION: #{msg}"
          warning += " See: #{opt.url}" if opt.url
          console.debug warning
        already_shown.push msg
    )()
    

    JS:

    Ember.deprecate = (function() {
      var already_shown = [];
      return function (msg, test, opt) {
        if (test) return false;
        if (already_shown.indexOf(msg) === -1) {
          var warning = 'DEPRECATION: ' + msg;
          if (opt.url) {
            warning += ' See: ' + opt.url;
          }
          console.debug(warning);
        }
        already_shown.push(msg);
      };
    })();
    

提交回复
热议问题