res.statusCode in the request errored message is inaccurate b/c the Koa Context error handler has not yet run
Generating two messages instead of one for the request is not ideal IMO
From studying onResFinished in pino-http, it looks like koa-pino-logger should set res.err and make res.status a proxy for res.statusCode instead calling ctx.log.error.
I noticed that koa-pino-logger depends on outdated versions of pino-http and koa, so I suppose there is an opportunity to update those deps and make the koa-pino-logger experience more congruent with pino-http.
If a request promise is rejected, koa-pino-logger will log a
request errored
message, then pino-http will log arequest completed
message.Consider this app:
Here's the output:
These are the oddities I see:
res.statusCode
in therequest errored
message is inaccurate b/c the Koa Context error handler has not yet runFrom studying
onResFinished
in pino-http, it looks like koa-pino-logger should setres.err
and makeres.status
a proxy forres.statusCode
instead callingctx.log.error
.I noticed that koa-pino-logger depends on outdated versions of pino-http and koa, so I suppose there is an opportunity to update those deps and make the koa-pino-logger experience more congruent with pino-http.