@zishone/logan
TypeScript icon, indicating that this package has built-in type declarations

0.1.4 • Public • Published

logan NPM Build codecov License

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.

Readme

Keywords

Package Sidebar

Install

npm i @zishone/logan

Weekly Downloads

1

Version

0.1.4

License

MIT

Unpacked Size

16.6 kB

Total Files

18

Last publish

Collaborators

  • zishone