koa-visit-logger
v1.0.3
Published
Logging middleware for koa
Downloads
43
Maintainers
Readme
koa-visit-logger
Development style logger middleware for koa.
<-- GET /
--> GET / 200 835ms 746b
<-- GET /
--> GET / 200 960ms 1.9kb
<-- GET /users
--> GET /users 200 357ms 922b
<-- GET /users?page=2
--> GET /users?page=2 200 466ms 4.66kb
Installation
$ npm install koa-visit-logger
Example
const Koa = require('koa')
const logger = require('koa-visit-logger')
const app = new Koa()
app.use(logger())
Notes
Recommended that you .use()
this middleware near the top
to "wrap" all subsequent middleware.
Options
// default option
const defaults = {
appName: 'app',
dailyRotateFile: {
datePattern: 'YYYY.MM.DD.HH',
maxSize: '100m',
maxFiles: '15d'
},
domain: path.join(path.dirname(__dirname), '../logs'),
fileName: 'app',
handler: () => { },
transporter: () => { }
}
Use Custom Transporter
const Koa = require('koa')
const logger = require('koa-visit-logger')
const app = new Koa()
app.use(logger({
handler: data => {
// ...
},
transporter: data => {
// ...
}
}))