Console log style

HTML
CSS
JAVASCRIPT
var consoleStyles = { 'good': 'padding: 0 .5rem; background: forestgreen; font: 1.6em/1 Arial; color: white;', 'info': 'padding: 0 .5rem; background: midnightblue; font: 1.6em/1 Arial; color: white;', 'warn': 'padding: 0 .5rem; background: orangered; font: 1.6em/1 Arial; color: white;', 'error': 'padding: 0 .5rem; background: crimson; font: 1.6em/1 Arial; color: white;' }; function log ( msg, style ) { if ( !style || !consoleStyles[ style ] ) { style = 'bold'; } console.log ( '%c' + msg, consoleStyles[ style ] ); } var str = 'Anything...'; log ( str, 'good' ); log ( str, 'info' ); log ( str, 'warn' ); log ( str, 'error' );
Expand for more options Login