项目作者: wcastand

项目描述 :
auto format console with chalk
高级语言: JavaScript
项目地址: git://github.com/wcastand/niceuho.git
创建时间: 2018-11-01T20:49:54Z
项目社区:https://github.com/wcastand/niceuho

开源协议:

下载


niceuho

auto format console output with chalk for node

console.log, .info, .warn, .error doesn’t have a specific color scheme in a terminal with node. (it exists mostly to miror console api for browser)

So i created a simple package that use chalk to add some colors and style to console’s api for node.

Install

  1. $ npm install niceuho
  2. // or
  3. $ yarn add niceuho

Usage

Default config

  1. require('niceuho')
  2. console.log("Hello") // output white Hello by default
  3. console.warn('Warning !') // output yellow Warning ! by default

Custom config

  1. require('niceuho')({ log : 'blue', error : ['bold', 'underline', 'red'] })
  2. console.log("Hello") // output blue Hello
  3. console.error('Error !') // output "Error !" in bold red and underlined

You can use all the modifiers from chalk in the custom (accept a string or an array of string)
In the config you can customize log, info, warn and error.

Warning

In order to get a proper formatting you have some constraints.
If you want to show an object for example you’ll have to use the node’s util format syntax.

console.log("object : %o", myobj)

You can find more information here : util