koa-better-log
v1.0.5
Published
Koa middleware logging requests.
Downloads
1,094
Readme
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 istrue
logger
: function to log info with, default isconsole.log
json
: boolean to enable logging as json output, default istrue
logWith
: function receivingctx
as argument and returning additional properties to loginclude
: function receivingctx
as argument and returningbool
indicating whether to do log requestexclude
: function receivingctx
as argument and returningbool
indicating whether to not log request