consolable

get controls and colors in your nodejs native console

consolable - get controls and colors in your nodejs native console.

you have good command of console.error, warn, info, log.

  • NodeJS

Start coding:

$ npm install consolable

Include in your project

require('consolable');
  • Discarding lower level of log.
  • Visualize log by color, tag and time.
  • Output logs to file.
var consolable = require('consolable');
  • Set stdout log level, default 4.
    • level is [specific string](#Level Format Word Lists) or number.
    • sync is true, sync file log level with log level.
  • Lower level of logs will be discarded.
    • level 0: No logs output.
    • level 1: error.
    • level 2: error, warn.
    • level 3: error, warn, info.
    • level 4: error, warn, info, log.
consolable.setLogLevel 3            # Set Lv.3 
consolable.setLogLevel '2'          # Set Lv.2 
consolable.setLogLevel 'production' # Set Lv.1 
consolable.setLogLevel 'hoge'       # Set Lv.4,  word 
consolable.setLogLevel 4yes       # Set Lv.4, set FLv.4 
  • Set file log level, default 4.
  • Lower level of logs will be discarded.
  • Output logs to file, default null.
  • If path is already exists, append log.
consolable.setFilePath './log.txt'
consolable.setFilePath null         # Stop 
  • Append UnixTime to log prefix, default false.
consolable.setAppendTime()
console.log 'hoge'           # [1354605544707 log] hoge 
 
consolable.setAppendTag no
console.log 'hoge'           # [1354605544707] hoge 
 
consolable.setAppendTime no
console.log 'hoge'           # hoge 
 
  • Append LogLevel to log prefix, default true.
consolable.setAppendTag()
console.log 'hoge'           # [log] hoge 
 
consolable.setAppendTag no
console.log 'hoge'           # hoge 
  • Colorize body text, default false.
consolable.setColorize()
console.log 'colorize..'     # <color=cyan>[log] colorize..</color> 
 
consolable.setColorize no
console.log 'colorize..'     # <color=cyan>[log]</color> colorize.. 
  • Change log color, defaults...
    • error red
    • warn yellow
    • info grey
    • log cyan
consolable.setColor 'error''magenta'
consolable.setColor 1'blue'
consolable.setColor 'info''green'

  • 0, none
  • 1, error, production
  • 2, warn
  • 3, info
  • 4, log, debug, development
  • white
  • grey
  • black
  • blue
  • cyan
  • green
  • magenta
  • red
  • yellow