Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

consolable

geta638MIT1.0.2

get controls and colors in your nodejs native console

console, color, level, log, logger

readme

consolable

consolable - get controls and colors in your nodejs native console

Requirement

  • NodeJS

Quick Start

Start coding: $ npm install consolable

Include in your project require('consolable');

How to Use

require('consorable');

Methods

var consolable = require('consolable');
  • consolable.level(level)

    • ログレベルを変更します、Level Formatセクションにある語で指定できます
    • デフォルトは4です
  • consolable.tag(bool)

    • タグによるプレフィックスを付与するかどうかを変更します
    • デフォルトはtrueです、引数を与えないとトグルします
  • consolable.colorize(bool)

    • ログの本文にカラーを付与するかどうかを変更します
    • デフォルトはfalseです、引数を与えないとトグルします
  • consolable.color(level, color)

    • ログのカラーを変更します、第1引数はLevel Format、第2引数はColor Formatです
    • デフォルトは次の通りです
      • error : red
      • warn : yellow
      • info : grey
      • warn : cyan

Level Format

Level 0

0, none

Level 1

1, error, production

Level 2

2, warn

Level 3

3, info

Level 4

4, log, debug, development

Color Format

grayscale

white, grey, black

colors

blue, cyan, green, magenta, red, yellow

Features

  • control show/hide logs by loglevel option.
  • append colorized tag for message.

Example

var consolable = require('consorable');

consolable.level(2);

console.log('test');      // ignored
console.info('test');     // ignored
console.warn('warn');     // [warn] warn      // [warn] is yellow color
console.error('!ERROR!'); // [error] !ERROR!  // [error] is red color

consolable.level(4);

console.log('test');      // [log] test

consolable.tag(false);

console.log('test');      // test

consolable.colorize(true);

console.log('test');      // test // (cyan color)
console.error('FIXME');   // FIXME // (red color)

consolable.color('error', 'blue');

console.error('FIXME');   // FIXME // (blue color)