Name Last Update
..
History.md Loading commit data...
LICENSE Loading commit data...
README.md Loading commit data...
index.js Loading commit data...
package.json Loading commit data...

koa-morgan

HTTP request logger middleware for koa.
morgan wrapper for koa's middleware.

NPM version NPM Downloads Build status Test coverage Dependency status License

Install

$ npm install --save koa-morgan

Usage

=1.x, 100%, working with morgan and koa-v2

const fs = require('fs')
const Koa = require('koa')
const morgan = require('koa-morgan')

// create a write stream (in append mode)
const accessLogStream = fs.createWriteStream(__dirname + '/access.log',
                                             { flags: 'a' })
const app = new Koa()

// setup the logger
app.use(morgan('combined', { stream: accessLogStream }))

app.use((ctx) => {
  ctx.body = 'hello, world!'
})

app.listen(2333)

=0.x, working with koa-v1

var koa = require('koa');
var morgan = require('koa-morgan');
var app = koa();

app.use(morgan.middleware(format, options));