Open soonfy opened 6 years ago
const logger = (format) => {
const reg = /:(\w+)/g;
return async (ctx, next) => {
let str = format.replace(reg, (match, property) => ctx[property]);
console.log(str);
await next();
}
}
app.use(logger(':method :url'));
soonfy
koa middleware
koa
koa-logger
koa-router
koa-bodyparser
koa-ejs
koa-static
koa-cors
soonfy 2018-03-31