express-logging-json
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

express-logging-json

A JSON logging helper for Express

Installation

npm install express-logging-json

Usage

A simple logging middleware example, with on-finished module:

const onFinished = require('on-finished');
const format = require('express-logging-json');

const options = {
    mask: {
        fields: ['headers.authorization']
    }
};

const app = express();

app.use((req, res, next) => {
    onFinished(res, err => {
        const log = format(req, res, options);
        log.err = err;
        console.info(log);
    });
    next();
});

Package Sidebar

Install

npm i express-logging-json

Weekly Downloads

32

Version

0.0.1

License

MIT

Unpacked Size

12.7 kB

Total Files

11

Last publish

Collaborators

  • openrm