npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

consoleplusplus

v1.4.4

Published

Console++ - enhance your console

Downloads

1,879

Readme

NPM version Build Status FOSSA Status

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 one-liner?

npm install consoleplusplus

How does it make it awesomeR?

Like this:

// here console is not that awesomeR

require("consoleplusplus");
// 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");

console.info("A (somewhat important) console.info 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:

[LEVEL - TIMESTAMP] THE_MESSAGE

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";
console.debug(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`
console.getLevel();
console.getLevelName(level);
console.getLevelColor(level);
console.isLevelVisible(levelToCompare);

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

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

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

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

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

Limitations

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

Links

  • On NPM: https://npmjs.org/package/consoleplusplus
  • On GitHub: https://github.com/detro/consoleplusplus

Keep calm and make awesome.

License

This project is licensed under BSD 3-Clause "New" or "Revised" License.

FOSSA Status