Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide source of Log messages in Console?

When outputting messages into the console, the source is also displayed (in Chrome Developer Tools it's on the right):

console.log("Foo");                         //Source Foo                               test.js:1 //Output 

However, on some sites, messages are displayed without the source being displayed, such as on Facebook:

Console screenshot on Facebook.com

Having a look on the Chrome Console API Reference there are examples across a ton of different outputs but all of them have the source displayed.

How can I hide the source (.js page and line number) of console outputs?


Edit: Just for clarification, this is not a duplicate of How does Facebook disable the browser's integrated Developer Tools? as that question answers how the console disables standard user input (and its answers explain how it works). I am specifically asking about the aesthetic of not displaying the source file and line.

like image 633
Ben Avatar asked Jan 13 '16 09:01

Ben


People also ask

How do I hide iframe messages?

In Chrome's Console tab you have a Filter box, type there the name of the file you want to filer out, with a minus sign "-" before the file name. You can filter multiply files, using space as a delimiter. Or instead of typing, just right click on a log message, and select Hide message from <file_name> .


1 Answers

They are using setTimeout to detach from the source:

setTimeout(console.log.bind(console, '\n%c' + s[0], s[1])); 
like image 74
Oliver Salzburg Avatar answered Sep 24 '22 09:09

Oliver Salzburg