standard-log-color
TypeScript icon, indicating that this package has built-in type declarations

12.1.2 • Public • Published

standard-log-color

NPM version NPM downloads

Github NodeJS Codecov

Visual Studio Code

[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!')

Rendering example

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' })

Readme

Keywords

none

Package Sidebar

Install

npm i standard-log-color

Weekly Downloads

921

Version

12.1.2

License

MIT

Unpacked Size

293 kB

Total Files

125

Last publish

Collaborators

  • unional