How do I disable firefox console from grouping duplicate output?

后端 未结 5 1537
悲&欢浪女
悲&欢浪女 2020-12-16 09:41

Anyone knows how to avoid firefox console to group log entries?

I have seen how to do it with firebug https://superuser.com/questions/645691/does-firebug-not-always

相关标签:
5条回答
  • 2020-12-16 10:19

    Update

    Firefox team added option to group similar messages, which is enabled by default.

    You can access to this option via Console settings

    • Open up Firefox's dev tools
    • Select Console tab
    • Click on gear button (placed at the right of the toolbar)
    • Change the option as you wish

    Original Answer

    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

    0 讨论(0)
  • 2020-12-16 10:19

    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.

    0 讨论(0)
  • 2020-12-16 10:23

    There is a settings menu () at the right of the Web Console's toolbar now which contains ✓ Group Similar Messages:

    0 讨论(0)
  • 2020-12-16 10:35

    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());

    0 讨论(0)
  • 2020-12-16 10:41

    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
    
    0 讨论(0)
提交回复
热议问题