koa-better-log

1.0.5 • Public • Published

koa-better-log

Koa middleware logging requests.

Usage

Install:

yarn add koa-better-log

Usage:

import koa from 'koa';
import log from 'koa-better-log';
 
const app = new koa()
app.use(log());

Output:

curl localhost
 
{
  time'2020-07-18T19:36:12.079Z',
  timestamp: 1595100972079,
  name: 'webapp',
  version: '1.0.0',
  ip: '::1',
  method: 'GET',
  url: '/?fingerprint=23',
  status: 200,
  bytes: '709B',
  duration: '1ms'
}

Options

  • pretty: boolean to enable or disable pretty formatting of duration and size, default is true
  • logger: function to log info with, default is console.log
  • json: boolean to enable logging as json output, default is true
  • logWith: function receiving ctx as argument and returning additional properties to log
  • include: function receiving ctx as argument and returning bool indicating whether to do log request
  • exclude: function receiving ctx as argument and returning bool indicating whether to not log request

Readme

Keywords

none

Package Sidebar

Install

npm i koa-better-log

Weekly Downloads

83

Version

1.0.5

License

MIT

Unpacked Size

4.13 kB

Total Files

6

Last publish

Collaborators

  • damianobarbati