• Stars
    star
    140
  • Rank 261,473 (Top 6 %)
  • Language
    JavaScript
  • License
    BSD 3-Clause "New...
  • Created almost 12 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Console++ - enhance your console

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

Keep calm and make awesome.

License

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

FOSSA Status

More Repositories

1

ghostdriver

Ghost Driver is an implementation of the Remote WebDriver Wire protocol, using PhantomJS as back-end
Java
1,915
star
2

phantomjs-jasminexml-example

PhantomJS - Jasmine XML - Example Project Layout
JavaScript
41
star
3

jasmine-jsreporter

Jasmine JS Reporter - The purpose of this reporter is to make it easier to extract informations about the executed Test Results, without having to parse the DOM. The results are just a plain JavaScript Object (aka JSON)..
JavaScript
19
star
4

coding-exercises

The kind of stuff a Developer will meet in his life when he is 1) studying for exams 2) preparing for interview 3) having fun. Nothing structured or organized: just plain C, C++ and possibly other languages to come.
C
15
star
5

.bashrc.d

My personal ~/.bashrc.d
Shell
11
star
6

qtoolbox

qtoolbox is a set of tools for everyday Qt development
C++
9
star
7

gredirector

Permanent Redirect URLs (HTTP 301 Status Code) through Google App Engine
Python
6
star
8

srvzio

An helpful crate to implement services
Rust
6
star
9

browsermob-proxy-client

Java client library to install, launch and control a BrowserMob Proxy exclusively via it's REST API
Java
5
star
10

node-caronte-proxy

Simple HTTP(S) Proxy, suitable to test proxying during development
JavaScript
5
star
11

sulfur

Sulfur - Just one more level of abstraction
Java
4
star
12

rock-paper-scissors

Implementation of Rock-Paper-Scissors as Java based webapp, made of a RESTful API + WebUI
Java
3
star
13

QDetroBro

Qt on S60 based Browser. It's experimental, non-functionally complete (not even trying to), and rips off code from the great Qt Labs example applications.
C++
2
star
14

detro.github.io

ivandemarino.me blog, pages and more madness
Less
2
star
15

bytes_parser

A simple wrapper to parse primitive Rust types from a slice of bytes.
Rust
2
star
16

CronExplainer

This is a simple utility, written in Java and using Gradle, that accepts as input arguments a line of Cron configuration, and prints out an _"explaination"_ for it.
Java
1
star
17

go-checkit

Go
1
star
18

timesince.js

Forward Counter (JavaScript utility)
JavaScript
1
star
19

jsonconf

JSON based configuration utility with some cool features
Java
1
star
20

detro

1
star