4.0.3 • Published 3 years ago

@quickcase/node-logging v4.0.3

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

node-logging

Build status npm version

NodeJS logging component for QuickCase applications.

Some background info:

  • there are 6 log levels: trace (5), debug (4), http (3), info (2), warn (1) and error (0).
  • log level can be set via an environment variable LOG_LEVEL, the default is info.
  • log output can be set to json, pretty print json and printf by setting environment variable LOG_FORMAT to either prettyprint or printf or json. The default is json.
  • by default logging is turned off when running the unit tests.

Usage

Add it as your project's dependency:

npm i @quickcase/node-logging

Require it:

const logger = require('@quickcase/node-logging')('moduleName')

Usage are:

logger.info({
  message: 'Yay, logging!'
})

or

logger.log({
  level: 'info',
  message: 'What time is the testing at?'
});

Above will result in the following log printed (if JSON format is enabled).

{
  level: 'info',
  message: 'What time is the testing at?',
  name: 'moduleName',
  timestamp: '2021-01-30T17:57:26.875Z'
}

Access logging for Express applications

Optionally you can use the built-in Express access logger:

const { Express } = require('@quickcase/node-logging')

app.use(Express.accessLogger())

Units Tests

Just do

npm test

License

This project is licensed under the MIT License - see the LICENSE file for details.

4.0.3

3 years ago

4.0.2

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago

4.0.0-rc.1

3 years ago

4.0.0-rc.0

3 years ago

3.0.3

3 years ago