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

Child log level in bindings is deprecated #3896

Merged
merged 3 commits into from Jun 1, 2022
Merged

Child log level in bindings is deprecated #3896

merged 3 commits into from Jun 1, 2022

Conversation

orov-io
Copy link

@orov-io orov-io commented May 11, 2022

Update Logger types to add options to the child function.

ChildLoggerOptions and redactOptions interface was copied from the pino library types.

logger test runs.

@github-actions github-actions bot added the typescript TypeScript related label May 11, 2022
Copy link
Member

@climba03003 climba03003 left a comment

Choose a reason for hiding this comment

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

Can you add a test in https://github.com/fastify/fastify/blob/main/test/types/logger.test-d.ts
It can ensure the type is working properly

@orov-io
Copy link
Author

orov-io commented May 11, 2022

like this?

const loggerChild = fastify({
  logger: true
}).log.child({}, {level: 'trace'})

expectType<FastifyLoggerInstance>(loggerChild)

I'm not pretty sure about how to test it in another way

@climba03003
Copy link
Member

climba03003 commented May 11, 2022

like this?

const loggerChild = fastify({
  logger: true
}).log.child({}, {level: 'trace'})

expectType<FastifyLoggerInstance>(loggerChild)

I'm not pretty sure about how to test it in another way

Mostly, correct.

const childParent = fastify().log
// we test different option variant here
expectType<FastifyLoggerInstance>(childParent.child({}, { level: ... }))
expectType<FastifyLoggerInstance>(childParent.child({}, { redact: ... }))
expectType<FastifyLoggerInstance>(childParent.child({}, { serializers: ... }))
expectType<FastifyLoggerInstance>(childParent.child({}, { level: ..., redact: ..., serializers: ... }))

// no option pass
expectError(childParent.child())
// wrong option
expectError(childParent.child({}, { nonExist: true }))

@orov-io
Copy link
Author

orov-io commented May 11, 2022

ok, I need to return to my work for others stuffs, I'll push the test ASAP :)

@kibertoad
Copy link
Member

@orov-io ping?

Copy link
Member

@climba03003 climba03003 left a comment

Choose a reason for hiding this comment

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

LGTM.

@kibertoad kibertoad merged commit 68a290d into fastify:v3.x Jun 1, 2022
@kibertoad kibertoad mentioned this pull request Jun 1, 2022
4 tasks
@github-actions
Copy link

github-actions bot commented Jun 2, 2023

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
typescript TypeScript related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants