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

Instantiating synchronous pino-pretty logger with fastify 5 #1060

Closed
kibertoad opened this issue Sep 28, 2024 · 2 comments
Closed

Instantiating synchronous pino-pretty logger with fastify 5 #1060

kibertoad opened this issue Sep 28, 2024 · 2 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@kibertoad
Copy link
Member

kibertoad commented Sep 28, 2024

💬 Question here

Previously this was the way to instantiate a synchronous pino-pretty logger (which is very convenient for tests):

import pretty from 'pino-pretty'

    const logger = pino(
      pretty({
        sync: true,
        minimumLevel: appConfig.logLevel as Level,
        colorize: true,
        translateTime: 'SYS:standard',
        ignore: 'hostname,pid',
      }),
    )

  const app = fastify({
    logger
  })

Unfortunately, this no longer works, because fastify 5 only supports logger configuration but not preinstantiated logger. How does one use pino-pretty while still respecting the sync attribute now?

Your Environment

  • node version: 20
  • fastify version: >=5.0.0
@kibertoad kibertoad added the help wanted Extra attention is needed label Sep 28, 2024
@dosubot dosubot bot added the question Further information is requested label Sep 28, 2024
@mcollina
Copy link
Member

Use fastify({ loggerInstance: logger }) This is mentioned in the migration guide.

@kibertoad
Copy link
Member Author

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants