@quickcase/node-logging

4.0.3 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i @quickcase/node-logging

Weekly Downloads

148

Version

4.0.3

License

MIT

Unpacked Size

25 kB

Total Files

17

Last publish

Collaborators

  • vlaurin