Skip to content

Instantiating synchronous pino-pretty logger with fastify 5 #1060

Closed
@kibertoad

Description

@kibertoad

💬 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions