8

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?

2 Answers 2

4

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.

4
  • I use the console myself to the max.. colors.. groupConsole.. the lot. If I noop I can't do my job. This Framework thing feels like pre-ordering a Tesla S3 and getting a lead-battery in advance Commented Aug 25, 2016 at 7:06
  • Using the idea above you'll be able to log. The code needs help though, since I wrote it on my phone. ;)
    – iOnline247
    Commented Aug 25, 2016 at 20:53
  • I've updated the code @Danny'365CSI'Engelman.
    – iOnline247
    Commented Aug 27, 2016 at 23:47
  • nice! One could work in their own log code, and still have it removed with Uglify I wrapped it in some extra JavaScript magic so this code is removed from minified versions as well Commented Aug 28, 2016 at 8:00
5

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

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.