0.0.4 • Published 10 years ago

chalkformat v0.0.4

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

chalkformat

formatted console logging with chalk for Node.js

Usage

var parseFormats = require("chalkformat");

var logger = parseFormats([
   {value:'[', styles:'bold.red'},
   {value:'ERROR', styles:'bold.yellow'},
   {value:']', styles:'bold.red'},
   {value:'$0',styles:'bold.cyan'}
]);

console.log(logger('oops, I did it again'));

which would result in this:

screenshot

Each format block is a value that is printed out, and a chalk style string. if you specify a value with '$n', where n is a number, then a function argument is used for output. In the example. the last format block uses $0, which would print out the first argument passed to the generated function.

Styles can be chained. just separate them with periods. The example above is using both a bold and a color style on each value.

If the style string is not a valid chalk style, or empty, then the value in the format object is returned unmodified.

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago