Console logging with colors, done as simply as it gets.
Consolomatic is an extension of the existing node global Console object to allow coloring of console messages. Unlike other console coloring modules you dont need to write your log/info/war/error calls any differently.
npm install consolomatic
//import in any file you want colored messages
import console from 'consolomatic'
//use like normal
console.log('A log message');
console.info('An info message');
console.warn('A warning message');
console.error('An error message');
import console, {colours} from 'consolomatic';
//customize the color of console methods
console.setColor('warn', colors.magenta);
console.warn('All warn messages are now magenta');
//Use colors inside template strings to color specific words or parts of messages
console.info(`A message with a ${colors.green}green${colors.reset} word`);
var console = require('consolomatic').default;
var colors = require('consolomatic').colors;
//the rest is the same
console.log('A log message');
All of the existing console methods (e.g. .count, .time) work as before. Also, the 'colorised' console methods will still format supplied parameters just like the native methods.
import console, {colours} from 'consolomatic';
//customize the color of console methods
console.setColor('warn', colors.magenta);
console.warn('All warn messages are now magenta');
import console, {colours} from 'consolomatic';
console.addConsoleMethod('green', colors.green);
console.green('A completely green message');
import console from 'consolomatic';
console.overrideGlobal();
If you want colored console messages in the entire project but dont want to import consolomatic in every file, you can call overrideGlobal to override the global.console. Due to the way that imports are evaluated (imported module is evaluated before its parent module) you'll need to make this call from an imported 'setup' file see example in examples/example_global_override.js
- black
- red
- green
- yellow
- blue
- magenta
- cyan
- white
- bgBlack
- bgRed
- bgGreen
- bgYellow
- bgBlue
- bgMagenta
- bgCyan
- bgWhite
support for these varies by platform
- reset
- bright
- dim
- underscore
- blink
- reverse
- hidden