logchalk

a stupid simple console.log wrapper with chalk colors


License
MIT
Install
npm install logchalk@1.0.1

Documentation

ChalkLog

A simple wrapper for the ubiquitous Chalk package that allows you to log color to your terminal with a single function call.

Basic Usage

const log = require('chalklog')

log('hello') // console.log('hello')
log.green('hello') // console.log(chalk.green('hello'))
log`{green hello}` // console.log(chalk`{green hello}`)

Tagged Template Literal Syntax

Also supports Chalk's tagged template literal syntax:

const var1 = "hello"
const var2 = "hello"

log`
{green ${var1}}
{rgb(255,131,0) ${var2}}
`

Call-Chaining

As an added bonus, all calls to log() return the log function itself, so you can issue multiple log calls on a single line:

log('foo').green('bar')('baz')

// RESULT:
// foo -> white
// bar -> green
// baz -> white

A common use-case for this is to simply add an extra line break in your terminal output:

log('hello')()
log('world')

// RESULT:
// hello
//
// world