Christian Neverdal
Christian Neverdal

Reputation: 5375

Messages shown in the developer console in spite of "error" filtered

I have a lot of "action" entries in my log. When I switch to "Errors only", these still appear (though each entry is empty - presumably those are not error messages).

How can I get rid of these?

Actions

Upvotes: 2

Views: 247

Answers (1)

Salman Arshad
Salman Arshad

Reputation: 272006

The downward pointing triangles indicate that these messages are generated by console.group function which is not affected by the filter. The functions that are affected by the filter are console.log, console.info, console.warn and console.error.

If you run the following code sample with filters you will notice that the content inside groups is affected by the filters but the group itself is not:

console.clear();
for (i = 0; i < 10; i++) {
  console.group("Group %d", i);
  for (j = 0; j < 5; j++) {
    var fn = ["log", "info", "warn", "error", "debug"];
    var r = Math.floor(Math.random() * fn.length);
    console[fn[r]]("%s message", fn[r]);
  }
  console.groupEnd();
}

The solution is to overwrite the console.group and console.groupCollapsed function which honors the filters with your own implementation (e.g. console.group = console.groupCollapsed = function() {};).

Upvotes: 2

Related Questions