hapijs / hapi-pino

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

prettyPrint is deprecated #147

Closed thebrownfox closed 2 years ago

thebrownfox commented 3 years ago

Project throws an error after update to 9.0.0.

(node:8450) [PINODEP008] PinoWarning: prettyPrint is deprecated, look at https://github.com/pinojs/pino-pretty for alternatives.
/home/foxie/Dokumenty/Code/Artur/rutras-backend/node_modules/pino/lib/tools.js:221
    prettyFactory.asMetaWrapper = prettifierMetaWrapper
mcollina commented 3 years ago

This is not an error but a warning. Follow the instructions at https://github.com/pinojs/pino-pretty to remove it.

mcollina commented 3 years ago

Once you figure it out, would you like to send us a PR to update our docs?

thebrownfox commented 3 years ago

This is not an error but a warning. Follow the instructions at https://github.com/pinojs/pino-pretty to remove it.

Well, actually localhost crashed. 😅

TypeError: Cannot set properties of undefined (setting 'asMetaWrapper')
    at getPrettyStream (node_modules/pino/lib/tools.js:221:33)
    at normalizeArgs (node_modules/pino/lib/tools.js:433:16)
    at pino (node_modules/pino/pino.js:83:28)
    at Object.register (node_modules/hapi-pino/index.js:55:14)
    at internals.Server.register (node_modules/@hapi/hapi/lib/server.js:495:35)
    at start (index.js:121:15)
[nodemon] app crashed - waiting for file changes before starting...

Once you figure it out, would you like to send us a PR to update our docs?

Sure, I just changed prettyPrint option to false. However, I'd like to have the pretty print available. How can I use/configure pino transport/stream globally?

thebrownfox commented 3 years ago

This seems to work (taken from PR). Needs latest pino-pretty. This issue can be closed after the package is updated upstream and docs changed to reflect this usage.

    await server.register({
        plugin: HapiPino,
        options: {
            // Redact Authorization headers, see https://getpino.io/#/docs/redaction
            redact: ["req.headers.authorization"],
            transport: {
                target: "pino-pretty",
                options: {
                    colorize: true,
                    minimumLevel: "info",
                    levelFirst: true,
                    messageFormat: true,
                    timestampKey: "time",
                    translateTime: true,
                    singleLine: false,
                    mkdir: true,
                    append: true,
                },
            },
        },
    });
mcollina commented 2 years ago

Would you like to send a Pull Request to address this issue?