Customise console.log() when working with LWC

Let's look at how to customise console.log() statement.

When you work with LWC we have to use console.log() to debug the data.

Without this feature it becomes very hard to debug the data.

When you have lot of debug statements to look at, then it becomes very hard to differentiate one set of logs from another set.

Did you know that we can apply styles to console.log() such that it becomes a bliss to work with the logs in console.

Here is how you do it!

console.log('%c HEY! SALESFORCECASTS!!!! ', 'background: #222; color: #bada55');

Open you browser (Chrome), right click anywhere within the browser, click on inspect(a panel opens ups), now click on console tab with in the opened panel.

Copy and paste the code in the console panel of your browser and see what happens.