logan
A logger and log middleware. Why logan? Because it sounds like morgan.
Installation
$ npm i @zishone/logan
Usage
const express = require('express');
const { Logger, log } = require('@zishone/logan');
const app = express();
const logger = new Logger();
app.use(log(logger));
app.get('/get', (req, res) => {
// To log info
req.logger.info('Message', { /* any data */ });
// To log error
req.logger.error('Message', { /* any data */ });
// To log debug
req.logger.debug('Message', { /* any data */ });
// To add any data to per request log
req.addLogData({ /* any data */ });
// To add error data to per request log
req.addLogError(new Error());
res.send({});
});
app.listen(port, () => {
console.log('Listening at port 3000')
})
Authors
- Zishran Garces
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE file for details.