JavaScript
Switch branches/tags
Nothing to show
Latest commit 4cc7f7c Nov 30, 2017 @tigercosmos tigercosmos 1.1.0
Permalink
Failed to load latest commit information.
.circleci circle ci Nov 12, 2017
assets 1.0.2 Nov 27, 2017
.travis.yml travis Nov 12, 2017
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md Nov 9, 2017
LICENSE Create LICENSE Nov 9, 2017
README.md 1.1.0 Nov 29, 2017
change.log.md 1.1.0 Nov 29, 2017
index.js 1.1.0 Nov 29, 2017
package.json 1.1.0 Nov 29, 2017
test.js 1.1.0 Nov 29, 2017

README.md

Banner Build Status CircleCI npm version

Node Color Log

The more powerful logger for NodeJS.

node-color-log is a package for NodeJS. It provides more functions than the origin console.log. You can log text with colorful font and colorful background. Also, it has four levels log, including debug, info, warnand error. Give you much better experience while developing NodeJS projects.

Demo

Demo

Demo

Usage

Install

Install package in your project:

npm install node-color-log@latest --save

Import

Put the following code in your js in which you want to log.

const Logger = require('node-color-log');
const logger = new Logger();

Some parameters:

  • color includes: black, red, green, yellow, blue, magenta, cyan, white.

  • setting is optional, which is only used in colorLog, fontColorLog and bgColorlog. Keys in setting need to be boolean, and false by defualt.

let color = 'red';
let message = 'anything you will put into console.log';
const setting = {
    bold: true,
    dim: true,
    underscore: true,
    reverse: true,
    italic: true,
    strikethrough: true
}

log()

log with attributes, the order of setters can change.

NOTE: log() need to put behind of attribute setter(at the end).

joint() can connect different style of message in a line.

// normal log
logger.log(message)
// Attribute log
logger.color('red').bgColor('blue')
      .bold().italic().dim().reverse().underscore().strikethrough()
      .log(message);
// Joint log
logger.color('red').bold().log(message_style_1).joint()
      .bgColor('white').italic().log(message_style_2).joint()
      .strikethrough().log(message_style_3);

fontColorLog(), bgColorLog(), colorLog()

// only set font color
logger.fontColorLog('red', message, setting);
// only set background color
logger.bgColorLog('yellow', message, setting);
// set font and background color
logger.colorLog({
    font: 'black',
    bg: 'yellow'
}, message, setting);

debug(), error(), info(), warn()

With prefix that has background color

// debug level, with prefix "DEBUG: "
logger.debug(message);
// Error level, with prefix "ERROR: "
logger.error(message);
// Info level, with prefix "INFO: "
logger.info(message);
// Warn level, with prefix "WARN: "
logger.warn(message);

To see more example, you can check ./test.js.

Contribute

Any issues and PRs are very welcome!

Lisense

MIT