@quickcase/node-logging
v4.0.3
Published
NodeJS logging component for QuickCase applications
Downloads
665
Readme
node-logging
NodeJS logging component for QuickCase applications.
Some background info:
- there are 6 log levels:
trace
(5),debug
(4),http
(3),info
(2),warn
(1) anderror
(0). - log level can be set via an environment variable
LOG_LEVEL
, the default isinfo
. - log output can be set to json, pretty print json and printf by setting environment variable
LOG_FORMAT
to eitherprettyprint
orprintf
orjson
. The default isjson
. - 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.