Skip to content

pino.final does not work with pino-pretty #37

@eadaniel

Description

@eadaniel

When using pino.final with pino-pretty following exception is thrown:

only compatible with loggers with pino.destination and pino.extreme targets

We are using pretty-printing on the dev boxes and it took me quite a while that pino.final works fine without pino-pretty. Below you find code to reproduce the issue.

Best,
Alexander

const pino = require('pino')

const logger = pino({
  prettyPrint: true
})

const run = async () => {
  process.on('SIGTERM', pino.final(logger, (err, finalLogger) => {
    finalLogger.info('Graceful shutdown 1')
    finalLogger.info('Graceful shutdown 2')
    process.exit(0)
  }))

  await delay(30)
}

const delay = (secs) => {
  return new Promise((resolve, reject) => {
    setTimeout(() => resolve(), secs * 1000)
  })
}

run().catch(err => {
  logger.error({ err })
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions