color format for log

It can format output strings and make the console looks colorful.

###Format strings format has two arguments:

  • str --string to print to stdout.

  • opt --options like {fgc: 'red',bgc: 'yellow',eft: 'underline'}


  • fgc --foreground color(defalut 'white')

  • bgc --background color(defalut 'black')

you could use one of 'black','red','green','yellow','blue','magenta','cyan' or 'white'.

  • eft --effect (defalut 'reset').You could pass a string as 'underline' or an array as ['highlight', 'underline'].

you could use some of 'reset','highlight','dark','underline','flicker','inverse' or 'none'.


var format = require('format').format;
console.log(format('Hello world',{fgc:'red',bgc:'yellow',eft:'underline'}));

###Warn function Example:

var warn = require('format').warn;
warn('Hello world');

###Error function Example:

var error = require('format').error;
error('Hello world');

###Notice function Example:

var notice = require('format').notice;
notice('Hello world');

###Info function Example:

var info = require('format').info;
info('Hello world');


usage: format string [options]

  -f, --foreground  Set foreground color.
  -b, --background  Set background color.
  -v, --version     Print the version number and exit.
  -h, --help        Print help (this message) and exit.
  --er              effect reset
  --eh              effect highlight
  --ed              effect dark
  --eu              effect underline
  --ef              effect flicker
  --ei              effect inverse
  --en              effect none

  black            [  ][  ]
  red              [  ][  ]
  green            [  ][  ]
  yellow           [  ][  ]
  blue             [  ][  ]
  magenta          [  ][  ]
  cyan             [  ][  ]
  white            [  ][  ]