fastify / help

Need help with Fastify? File an Issue here.
https://www.fastify.io/
64 stars 8 forks source link

Instantiating synchronous pino-pretty logger with fastify 5 #1060

Closed kibertoad closed 1 week ago

kibertoad commented 1 week ago

💬 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

mcollina commented 1 week ago

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

kibertoad commented 1 week ago

thank you!