Simple logging library to reduce initialization and config options.
Basically just a wrapper around console.log
in a standard JSON output format.
npm i rsc-clean-log-json
const log = require('rsc-clean-log-json')
log.info(`Event saved`)
// { "level": "info", "message": "Event saved" }
log.error(`Error saving`, new Error(`database-offline`))
/*
{
"level": "error",
"message": "Event saving",
"attributes": {
"error": "database-offline",
"stack" "<stack trace>"
}
}
*/
log.warn(`Not too serious`, { userId: 1, name: 'John Doe'} )
/*
{
"level": "warn",
"message": "Not too serious",
"attributes": {
"userId": 1,
"name": "John Doe"
}
}
*/
log.debug()
log.info()
log.warn()
log.error()
log.alert()