Console++ - enhance your console
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information. More content for the README Feb 18, 2013
test Enable ability to not use equal spacing on all commands Aug 6, 2016
package.json 1.4.1 Aug 6, 2016

NPM version

Console++ - enhance your console

Console++ makes your console awesomeR. Colours, logging level and shit like that.

And it works with both PhantomJS and NodeJS (and pretty much any proper JavaScript runtime).

NPM stats NPM downloads

NPM one-liner?

npm install consoleplusplus

How does it make it awesomeR?

Like this:

// here console is not that awesomeR

// or
require("./console++.js"); //< if downloaded locally

// now console is very awesomeR!!!

Console++ adds a bit of sparkling power to your shy little console. It's not a fancy logging library with all the bells and whistles - it's a "poor man" logger that you can drop in your code without having to rewrite it.

Here is for the lazy developer!

How do I use it?

Ehm, like a console genius! Just type stuff like:

console.log("A (boring) console.log message");

console.debug("An (irrelevant) console.debug message");"A (somewhat important) message");

console.warn("A (quite important) console.warning message");

console.error("A (critical!) console.error message");

and you get:

alt text

No really, how?

Yes, it manipulates the console object (oh, the horror!) so that you can have some fancy colours, timestamped messages and a bit more. Output looks like:


Not all messages are printed. It introduces the concept of level (set via console.setLevel(level)): as you would expect, it goes from DEBUG (lowest, that corresponds to print all the things) to ERROR (highest, that corresponds to print only the errors).

By default the LEVEL portion of the message is coloured (see below how to disable this). Also, you can enable matching colouring for THE_MESSAGE (see methods listing below).

One nifty feature (I think) it's that you have fine-grained control over THE_MESSAGE. You can wrap text within #COLOR{TEXT_TO_COLOR} like:

var message = "#red{this} is #cyan{a} #yellow{nice} message";

to print something like:

alt text

PLEASE, do read the code to learn more.

How do I configure it?

Console++ adds some few little methods to the console so you can tune it a bit, based on your taste.

I'd like to be very lazy and say "go read the code", but I guess I can list here those methods.

console.LEVELS  = _LEVELS;

// Set/Get Level
console.setLevel(level);                //< default `DEBUG`

// Enable/Disable Colored Output
console.enableColor();                  //< default enabled

// Enable/Disable Colored Message Output
console.enableMessageColor();           //< default disabled

// Enable/Disable Timestamped Output
console.enableTimestamp();              //< default enabled

// Enable/Disable Equal Spacing on Level Name
console.enableEqualSpacing();           //< default enabled

// Set OnOutput Callback (useful to write to file or something)
// Callback: `function(formattedMessage, levelName)`
console.onOutput(callback);             //< default `null`


  • Characters { and } are reserved: using those will produce an undefined result


Keep calm and make awesome.