How do I disable firefox console from grouping duplicate output?

走远了吗. 提交于 2019-11-29 02:56:18

As I mentioned in comment section, There is no way to achieve this at the moment. maybe you should try to request this feature via Bugzilla@Mozilla

Also you can check Gaps between Firebug and the Firefox DevTools

As a workaround you can append a Math.random() to the log string. That should make all your output messages unique, which would cause them all to be printed. For example:

console.log(yourvariable+" "+Math.random());

Although you still cannot do this (as of August of 2018), I have a work-around that may or may not be to your liking.

You have to display something different/unique to a line in the console to avoid the little number and get an individual line.

I am debugging some JavaScript.

I was getting "Return false" with the little blue 3 in the console indicating three false results in a row. (I was not displaying the "true" results.)

I wanted to see all of the three "false" messages in case I was going to do a lot more testing.

I found that, if I inserted another console.log statement that displays something different each time (in my case, I just displayed the input data since it was relatively short), then I would get separate lines for each "Return false" instead of one with the little 3.

So, in the code below, if you uncomment this: "console.log(data);", you will get the data, followed by " Return false" instead of just "false" once with the little 3.

Another option, if you don't want the extra line in the console, is to include both statements in one: "console.log("Return false -- " + data);"

function(data){

   ...more code here...

    // console.log(data);
    console.log("Return false ");
    return false;
}

threeWords("Hello World hello"); //== True
threeWords("He is 123 man"); //== False
threeWords("1 2 3 4"); //== False
threeWords("bla bla bla bla"); //== True
threeWords("Hi"); // == False

To solve this for any browser, you could use this workaround: Override the console.log command in window to make every subsequent line distinct from the previous line.

This includes toggling between prepending an invisible zero-width whitespace, prepending a timestamp, prepending a linenumber. See below for a few examples:

(function()
{
    var prefixconsole = function(key, fnc)
    {
        var c = window.console[key], i = 0;
        window.console[key] = function(str){c.call(window.console, fnc(i++) + str);};
    };

    // zero padding for linenumber
    var pad = function(s, n, c){s=s+'';while(s.length<n){s=c+s;}return s;};

    // just choose any of these, or make your own:
    var whitespace = function(i){return i%2 ? '\u200B' : ''};
    var linenumber = function(i){return pad(i, 6, '0') + ' ';};
    var timestamp = function(){return new Date().toISOString() + ' ';};

    // apply custom console (maybe also add warn, error, info)
    prefixconsole('log', whitespace); // or linenumber, timestamp, etc
})();

Be careful when you copy a log message with a zero-width whitespace.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!