View on GitHub


colog - console.log with colors for Node.js

download .ZIPdownload .TGZ

colog Build Status


If you have Node.js and npm (Node Package Manager) installed, simply open console and type

npm install colog


To use colog, add it to your project file

var colog = require('colog');

Then you can start creating colorful output for your console:

colog.success('Up and running');

If you did everything right, after you start your program like this:

node myApplication.js

You should see green text "Up and running";

For more informations check Wiki page for this project


Predefined options:

colog.question('How are you ?');

Full list

Applying colors, effects or background:

colog.log(colog.colorGreen('My text'));
colog.log(colog.backgroundGreen('My text'));

Available effects:

Also you can use .b(), .u(), .s() and .i() etc.

Available colors:

Also you can use .colorBlack() instead of .black()

Available backgrounds:

Also you can use for example backgroundRed() instead of bgRed()


.nl() is alias for .newLine(). You get the point.

Combining multiple effects:

colog.log(colog.underscore(colog.colorRed('My text')));
colog.log(colog.apply('My text', ['underscore', 'colorRed']));
colog.log(colog.color('My text', 'red') + colog.color('My text', 'green'));
colog.format('<question>How are you ?</question>');
colog.format('colog.format(<bold><colorRed>This</colorRed></bold> <underline><yellow>is</yellow></underline> <green>SPARTA</green><inverse>!</inverse>);');
colog.log(colog.format('<question>How are you ?</question>', false));

All options that can be used as tags: bold, underline, strike, inverse, colorBlack, colorRed, colorGreen, colorYellow, colorBlue, colorMagenta, colorCyan, colorWhite, backgroundBlack, backgroundRed, backgroundGreen, backgroundYellow, backgroundBlue, backgroundMagenta, backgroundCyan, backgroundWhite

Also: now you can use short names like "black", "bgGreen" etc. Same as methods listed above

Progress bar

To init a progress bar with 1000 steps that is charged 50% (5000 steps) just use:

colog.progress(5000, 10000);

Now you can advance progress bar by .progress() method with one or no arguments:

colog.progress(); // will add one step to progress bar
colog.progress(5); // will add 5 steps

Formating output

Now .format() method allow You to combine string with arguments just like .format() method from Node.js Util library

colog.format('My name is %s and I\'m %d', 'Earl', 45);


Sometimes you want some description with status. This will print message on the left side of the screen and status on the right side. Script will measure size of your terminal and match position of both strings.

colog.status('Module message', '[OK]');
colog.status('Module <b>message</b>', '<b>[OK]</b>');

If script will be unable to check size of TTY, default cols will be used.

Silent mode

Sometimes you want Your colog to just shut up. You can do that using silent mode:


Dumping stuff

You can dump variables and functions at any point and apply effects to them.

colog.dump(variable, ['red', 'bgGreen']);

Example output


Author: Półtorak Dariusz License: MIT