Friends! Have you ever been developing, littered your code with console statements, and then realized you couldn't find what you were looking for? Have you ever wondered, "How can I make this console.log
statement stand out in a crowd?"
WONDER NO MORE!
You can provide a special %c
prefix to your logged string, and then all magical and printf-like, you can then provide some CSS to style up that line!
Here's a couple of examples that I was JUST using!
// In one file, in its `leave` method
console.log('%cleave called', 'color: red; font: 30pt Comic Sans MS; font-weight: bold');
// In another file, in its `_backupFocusables` method
console.log('%c_backupFocusables called', 'color: blue; font: 30px Comic Sans MS; font-weight: bold');
Once those were in place, I loaded my application, and just LOOK at how BEAUTIFUL my console is!
But wait! That's not all! You can use printf-style args in other places too! In fact, this trick works in MULTIPLE environments! *
Make your console prettier TODAY!