Skip to content

MaudDibb/chalkformat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

formatted console logging with chalk for Node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published