Am a big fan of the console, and apply it to the max (and I hate it, IE does not do colors in the console)

My console looks like this:

Now the SPFx output is cluttering up my precious console, with info that is not for me:

I can filter it with:

But that option is not sticky

Question:

  • Can we disable the console trace from SPFx libraries?
有帮助吗?

解决方案

noop it for now by adding this before any of the SPFx stuff gets loaded.

console.log(// extra wrapper so below code is taken out on minification
(function() {
    var noop = function noop() {};
    var methods = [
        'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
        'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
        'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
        'timeStamp', 'trace', 'warn'
    ];
    var length = methods.length;
    window.log = {};

    methods.forEach(function (method) {
        if (Function.prototype.bind && (typeof console === 'object' || typeof console === 'function') && typeof console.log === 'object') {
            console[method] = this.call(console[method], console);
        }
        if (console[method]) {
            window.log[method] = console[method].bind(console);
            console[method] = noop;
        }
    }, Function.prototype.bind);
  return "console is overriden"
})());

Then put it back the way it was or just use log instead. As an aside, it really shouldn't have shipped this way.

其他提示

No, that is not possible at this time. Interesting idea though. Can you as it a feature request to the github issue list?

许可以下: CC-BY-SA归因
scroll top