@pgprojectx/alchemy-koa-logging

1.1.0 • Public • Published

alchemy-koa-logging

Provides a uniform logging middleware for koa. Built on bunyan.

Installation

yarn add @pgprojectx/alchemy-koa-logging

or

npm install --save @pgprojectx/alchemy-koa-logging

Usage

alchemy-koa-logging requires a base bunyan instance to be provided.

Simple usage:

const Koa = require('koa');
const koaLogger = require('@pgprojectx/alchemy-koa-logging');
const bunyan = require('bunyan');

const logger = bunyan.createLogger({ name: 'my-service' });
const app = new Koa();
app.use(koaLogger(logger));

This will accomplish a few things:

  • A child logger will be created for each request and attached to ctx at ctx.logger.
  • Each request generates a unique identifier to trace. This is automatically attached to the child logger and available at ctx.state.request_id.
  • An access logger will log all requests with standard output.

Example output:

Readme

Keywords

none

Package Sidebar

Install

npm i @pgprojectx/alchemy-koa-logging

Weekly Downloads

2

Version

1.1.0

License

none

Last publish

Collaborators

  • lucasfrazier
  • mitchell0625
  • boggsey
  • btrane
  • joshuarose
  • mattgj
  • johndavidback
  • nogorilla
  • pgalchemy-ops