logger icon indicating copy to clipboard operation
logger copied to clipboard

Pass ctx to transporter

Open roark opened this issue 4 years ago • 2 comments

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...
}))

roark avatar Jan 05 '21 21:01 roark

When does it ship?

s4kr4 avatar Jul 22 '21 16:07 s4kr4

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);
});

libook avatar Oct 21 '21 09:10 libook