Skip to content

damianobarbati/koa-better-log

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Koa middleware logging requests.

Resources

Stars

Watchers

Forks

Packages

No packages published