Skip to content

byverdu/consColors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

consColors

Yet another npm package that prints colors in your console 🎉

But... the idea behind this module it's not that you can get crazy and print 1000s of different styles, this module gives you the ability to print log, warn or error messages to the stdout with a predefined message.

Have you found yourself doing something like this?

function Animal( name ) {
  this.name = name;
  .....
}

const lion = new Animal( 'Simba' );
const cat = new Animal( 'Garfield' );
const dog = new Animal( 'Scooby-Doo' );

console.log('lion:', lion);
console.log('cat:', cat);
console.log('dog:',dog);

The idea of this module is that by creating an instance of the logger you can omit the reference to the variable that you are trying to log the info.

const lionLogger = consColors( 'lion' );

lionLogger.log( 'hakuna matata' ); // lion: hakuna matata

How to use this package

The setup is quite easy, require the module and pass an object with 2 possible properties:

[type][string] required

Text to be logged any time that you call a method on the created instance.

[invert][boolean]

Use this option if you want to invert the color, i.e. rather than having the text in different colors force to have the background in different colors.

See examples and picture to have a better idea about the possible outputs.

const consColors = require( 'consColors' );

const consColorNormal = consColors({type: 'consColors'});
const consColorInvert = consColors({type: 'consColors', invert: true});

consColorNormal.log( 'This is a success example' );
consColorNormal.warn( 'This is a warn example' );
consColorNormal.error( 'This is an error example' );

consColorInvert.log( 'This is a success example with invert option' );
consColorInvert.warn( 'This is a warn example with invert option' );
consColorInvert.error( 'This is an error example with invert option' );

demo image with examples

About

Console output with colors and predefined text so you can easily trace what are you logging. To be used with Node

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published