/color-console

Primary LanguageTypeScriptMIT LicenseMIT

@makerx/color-console

Wraps chalk and console to provide a console interface which automatically formats tagged template literals with base text and interpolated arguments in different colours.

Installation

npm i @makerx/color-console --save

Example

import { colorConsole, createColorFormatter } from './index'
import chalk from 'chalk'

// Use the default colorConsole object
colorConsole.log`Example of log with args ${1}, ${2}, ${'three'}`
colorConsole.info`Example of info with args ${1}, ${2}, ${'three'}`
colorConsole.warn`Example of warn with args ${1}, ${2}, ${'three'}`
colorConsole.error`Example of error with args ${1}, ${2}, ${'three'}`
colorConsole.success`Example of success with args ${1}, ${2}, ${'three'}`

// Create your own custom formatter
const customLogger = createColorFormatter(chalk.magenta, chalk.greenBright, 'log', console)

customLogger`Example of custom with args ${1}, ${2}, ${'three'}`

will result in

Example output