1.1.0 • Published 5 years ago

colors-log v1.1.0

Weekly downloads
8
License
SEE LICENSE IN LI...
Repository
github
Last release
5 years ago

simple-colorful-console-log

A simple console log display module

Add

npm install colors-log

Init

require('colors-log')()

Usage

console.color('simple log!')

The console will show a log with a default color of yellow. You can also use the following method to show logs of other colors.

console.color.red('simple log!')

This module supports six color as follows, Use it as a method name to show logs:

  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan

Configuration

You can pass an object to configure when executes require(). The supported configuration items are as follows:

require('colors-log')({
    // default title displayed at the top of the log
    defaultTitle: 'title',
    // default color 
    defaultColor: 'blue',
    // The name of the method that the module mounts on the console
    functionName: 'colors'
})

Single log configuration

You can take a single configuration by passing an object to the second argument of the console.color method.

console.color('simple log!', {
    // this log's title
    title: 'custom title',
    // this log's color
    color: 'blue'
})

You can also pass a string to the second argument of the console.color[colorName] method to config the title of this log, as follows:

console.color.red('red log!', 'custom title')