standard-log-color
v12.1.2
Published
Color console reporter for `standard-log`
Downloads
2,539
Readme
standard-log-color
[standard-log-color] provides a log reporter that will color the logger id for standard-log.
This makes the log pops and is easier to spot where the log is coming from.
Install
npm install standard-log-color
yarn add standard-log-color
Usage
import { createStandardLog } from 'standard-log'
import { createColorLogReporter } from 'standard-log-color'
const standardLog = createStandardLog({
reporters: [createColorLogReporter({ ... })]
})
const log = standardLog.getLogger(...)
log.info('with color!')
By default, it will use ansi formatter in NodeJS and css formatter in browser.
If you want to change that, or use your own formatter:
import { createColorLogReporter } from 'standard-log-color'
createColorLogReporter({
formatter: yourFormatter
})
For createCssLogFormatter()
, you can specify how many colors to use:
import { createCssLogFormatter } from 'standard-log-color'
createCssLogFormatter({ maxColor: 30 })
You can also add timestamp
:
import { createAnsiLogFormatter, createCssLogFormatter } from 'standard-log-color'
createAnsiLogFormatter({ timestamp: 'none' })
createAnsiLogFormatter({ timestamp: 'iso' })
createAnsiLogFormatter({ timestamp: 'elapsed' })
createCssLogFormatter({ timestamp: 'none' })
createCssLogFormatter({ timestamp: 'iso' })
createCssLogFormatter({ timestamp: 'elapsed' })