@nthlytics/koa-bunyan-request-logger

1.0.1 • Public • Published

koa-bunyan-request-logger

Koa middleware that decorates the context object with a bunyan logger.

Usage

const Koa = require('koa');
const logMiddleware = require('@nthlytics/koa-bunyan-request-logger');

const app = Koa();

app.use(logMiddleware('Request Logger'));
app.use(async (ctx, next) => {
  // ctx.state.logger is a bunyan logger with the name 'Request Logger'
  // and a req_id property that has the value of the x-request-id header.
  ctx.state.logger.info('Made it this far');
  await next();
});

Package Sidebar

Install

npm i @nthlytics/koa-bunyan-request-logger

Weekly Downloads

1

Version

1.0.1

License

ISC

Unpacked Size

3.96 kB

Total Files

8

Last publish

Collaborators

  • nthlytics