1.0.1 • Published 7 years ago

@nthlytics/koa-bunyan-request-logger v1.0.1

Weekly downloads
1
License
ISC
Repository
-
Last release
7 years ago

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();
});