Colorful console logging
Add colors to your console output
Installation
Install with npm:
npm install @js-bits/log-in-color
Install with yarn:
yarn add @js-bits/log-in-color
Import where you need it:
import { green , css } from '@js-bits/log-in-color';
or require for CommonJS:
const { green , css } = require('@js-bits/log-in-color');
How to use
console.log(green('this message is green'));
or
console.log(green`Now: ${new Date()}`);
or
console.log(`RGB: ${red`red`}; ${green`green`}; ${blue`blue`}.`);
The approach above works in Chrome, Edge and Node.js.
All browsers should support a little different format:
console.log(...css(`RGB: ${red`red`}; ${green`green`}; ${blue`blue`}.`));
Use provided css()
function with a spread operator to convert colored string into a list of CSS styles.