logger
logger copied to clipboard
Pass ctx to transporter
Enables more verbose Transporter to log other ctx details. Fixes issues #77 and #82.
ctx
is passed as the 3rd argument to transporter as to not disrupt any existing code. That said, it could easily be the first argument if desired.
app.use(logger((str, args, ctx) => {
console.log(str, ctx.request.ip); // ctx.request.header['user-agent'], etc...
}))
When does it ship?
Anyone who waiting for this feature may do this temporarily:
import koaLogger from "koa-logger";
app.use(async (ctx, next) => {
const koaLoggerInstance = koaLogger(logString => {
// Do anything with ctx
});
await koaLoggerInstance(ctx, next);
});