Recommended that you .use() this middleware near the top to "wrap" all subsequent middleware.
const logger = require('koa-logger')
const Koa = require('koa')
const app = new Koa()
app.use(logger((str, args) => {
// redirect koa logger to other output pipe
// default is process.stdout(by console.log function)
}))
or
app.use(logger({
transporter: (str, args) => {
// ...
}
}))
Param str is output string with ANSI Color, and you can get pure text with other modules like strip-ansi
Param args is a array by [format, method, url, status, time, length]
koa-logger
官方仓库
https://github.com/koajs/logger
官方
npm
地址https://www.npmjs.com/package/koa-logger
https://npm.runkit.com/koa-logger
基础介绍
Development style logger middleware for koa. Compatible with request-received.
基础安装
基础使用
Recommended that you .use() this middleware near the top to "wrap" all subsequent middleware.
Param str is output string with ANSI Color, and you can get pure text with other modules like strip-ansi Param args is a array by [format, method, url, status, time, length]