1.2.0 • Published 1 year ago

@financial-times/community-js-logger v1.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

community-js-logger

Logger for community js projects

Usage

Installation

npm i @financial-times/community-js-logger

Logging

This library exports 4 log levels, debug, info, warn and error.

import logger from '@financial-times/community-js-logger'

logger.info({
    event: 'SOME_INTERESTING_EVENT',
    detail: {
        'oooh': 'isn\'t it interesting that this happened'
    }
})

logger.info({
    event: 'CALAMITY',
    error: new Error('some error object')
})

Setting the log level

Log level can be set via the LOG_LEVEL environment variable, or by setting logger.currentLogLevel to one of the below values:

  • SILENT : suppresses all log messages
  • DEBUG: includes debug logs, as well as info, warn and error logs.
  • INFO: includes info logs, as well as warn and error logs.
  • WARN: includes info logs, as well as error logs
  • ERROR: include only error logs