termcolor

console.color

termcolor

[Node.js] console.log, console.error with colors

git clone git://github.com/shinout/termcolor.git

OR

npm install termcolor
var tc = require("termcolor").define();
// remember to call define(), which defines methods under "console" object.

// var tc = require("termcolor").define;
// this is the same as define(), as termcolor internally use Object.defineProperty's getter/setter.
console.green("this is green"); // displays "this is green" with green color to STDOUT
console.cyan({hoge: "foobar"}, "multi args? N.P.");
console.log(tc.colors);
/* 
    ['black',
    'red',
    'green',
    'yellow',
    'blue',
    'purple',
    'cyan',
    'white']
 */
console.eblue("blue color, to stderr");
console.eyellow(["yellow color", "to stderr"], "of course, any value is acceptable");
var redstr    = tc.red("red string");
var purplestr = tc.purple("purple string");
console.log(redstr, purplestr);
console.bold("hoge")
console.bold("green", "BOLD GREEN")
console.purpleB("with B")
console.eyellowB("e [color] B")
console.color("green", "text with green color");
console.ecolor("red", "text with red color", "to stderr");