You can style your console output using CSS or output SVG similar to HTML.
We need to leverage the power of %c, much like this:
console.info(
"%c %cAdobe %cPhotoshop Web%c %c2023.23.0.1%c %c037a8af9746",
'padding-left: 36px; line-height: 36px; background-image: url("data:image/gif;base64,R0lGODlhIAAgAPEBAAAAAP///wAAAAAAACH5BAEAAAIALAAAAAAgACAAAAKkhC+py3zfopxGvIsztsCGD4La2FVAGBoBuZnox45WcqLsum5KDWdvf1nwTo+fLbgDqo7LFCJJbOY0oidt6ozVKrtib0qaCnlYcJh7rf5iK6HZaM64VeS6L+pWf89WT+6vRAUBBVQ1gpOTJ4IYdxCnOBSJ8ZhkZNekk5ZSxpTpt6Y1eEVm00j3VALDmBXVyPEJB2r2ShoLh2ASqvU60dsr5yuBUQAAOw=="); background-size: 32px; background-repeat: no-repeat; background-position: 2px 2px',
"background: #666; border-radius:0.5em 0 0 0.5em; padding:0.2em 0em 0.1em 0.5em; color: white; font-weight: bold",
"background: #666; border-radius:0 0.5em 0.5em 0; padding:0.2em 0.5em 0.1em 0em; color: white;",
"",
"background: #c3a650; border-radius:0.5em; padding:0.2em 0.5em 0.1em 0.5em; color: white;",
"",
"background: #15889f; border-radius:0.5em; padding:0.2em 0.5em 0.1em 0.5em; color: white;",
);
Similar to sprintf
in PHP, %c
will be replaced with the substitute and display: inline
will be applied to it.
It doesn’t matter whether you use console.log
or console.info
in this case.
For more info, visit this post Console Delight.