3.0.2 • Published 3 years ago

@officr/logger v3.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@officr/logger

Lightweight zeroconfig pretty logger.

Install

npm install --save-dev @officr/logger

Logging

import logger from '@officr/logger'

logger.debug('debug message only visible in DEBUG mode')
logger.log('log messages')
logger.info('info logging')
logger.warning('warning logging')
logger.errors('error logging')
logger.success('success logging')

with labels

const feature = logger.label('feature')

feature.debug('debug message')
feature.log('log messages')
feature.info('info logging')
feature.warning('warning logging')
feature.errors('error logging')
feature.success('success logging')

Config

/** apply config flags */
logger.config(flags: {
  /** whether to log to the console or not
   * @default true
   */
  console?: boolean

  /** whether to set a non zero exit code when errors
   * @default false
   */
  computeExitCode?: boolean

  /** whether to log the number of errors at exit
   * @default false
   */
  logStatsOnExit?: boolean

  /** whether to add timestamp
   * @default false
   */
  timestamp?: boolean
})

Streaming

record to a file

const stream = logger.record('path/to/log-file.log')

record to a json file

const stream = logger.record('path/to/log-file.log', json)

pipe to a stream

const stream = logger.pipe(...)

Stats

const { total, errors, warnings, success } = logger.stats()
3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.1.1

4 years ago

2.1.0

4 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago