1.0.5 • Published 5 years ago
koa-better-log v1.0.5
koa-better-log
Koa middleware logging requests.
Usage
Install:
yarn add koa-better-logUsage:
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 istruelogger: function to log info with, default isconsole.logjson: boolean to enable logging as json output, default istruelogWith: function receivingctxas argument and returning additional properties to loginclude: function receivingctxas argument and returningboolindicating whether to do log requestexclude: function receivingctxas argument and returningboolindicating whether to not log request