Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Koa-centric implementation - Provide an api with ctx instead of req/res #31

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jmealo
Copy link
Contributor

@jmealo jmealo commented Mar 9, 2021

I think the best way to support koa is to embrace it fully. I'm using this in a project for now but am open to becoming the maintainer of this package. This is what I came up with for now.

const maxInt = 2147483647
let nextReqId = 0
return function genReqId (ctx) {
// TODO: decide on order of keys, this matches current behavior of checking req.id

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmealo I don't think we need to add support for id on ctx.state.

The logging middleware should be the first or after an error middleware.

Adding on ctx.req would be the same as other pino adapters.

@stephanebachelier
Copy link

@jmealo I've tested your plugin in my current project. Looks great.
I've only an issue which is the same as the current logger implementation.
The log emitted when the HTTP response is finished does not contain some custom props I've set.

Child loggers used by the other middlewares receive the custom props and logs emitted does contain the custom props.

@jmealo
Copy link
Contributor Author

jmealo commented Mar 12, 2021

@stephanebachelier: I'm having an issue with log volume. I do not find it helpful that logging in the ctx on a request duplicates the entire line. Looking to possibly diverge completely and merge log entries differently.

Can you provide a failing test for your use case?

@Fdawgs
Copy link
Member

Fdawgs commented Dec 24, 2021

@jmealo are you still wanting to push forward with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants