hapijs / hapi-pino

🌲 Hapi plugin for the Pino logger
MIT License
148 stars 61 forks source link

Cannot get a custom pino instance with pino-pretty to work #187

Closed tcurdt closed 9 months ago

tcurdt commented 9 months ago

Runtime

nodejs

Runtime version

v20.11.0

Module version

12.1.0

Used with

hapi 21.3.3

Any other relevant information

Maybe this is related? https://github.com/hapijs/hapi-pino/issues/179

How can we help?

I am trying to use hapi-pino to log pretty print log messages to the console.


    const pino = Pino({
      transport: {
        target: 'pino-pretty',
        options: {
          colorize: true
        }
      }
    })

    return [
      {
        plugin: HapiPino,
        options: {
          instance: pino,
          level: 'info',
          logPayload: true,
          logQueryParams: true,
          logPathParams: true,
          log4xxResponseErrors: true,
        }
      }
    ]

Unfortunately it seems like the instance gets ignored.

It still just comes out as json:

{"level":30,"time":1707492507295,"pid":78397,"hostname":"foo","created":1707492506898,"started":1707492507295,"host":"foo","port":9000,"protocol":"http","id":"foo:78397:lsesyadu","uri":"http://foo:9000","address":"127.0.0.1","msg":"server started"}
tcurdt commented 9 months ago

Not sure what happened. After another npm i it seems to work now.