Instantiating synchronous pino-pretty logger with fastify 5
kibertoad opened this issue · 2 comments
kibertoad commented
💬 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
mcollina commented
Use fastify({ loggerInstance: logger })
This is mentioned in the migration guide.
kibertoad commented
thank you!