pinojs / pino-pretty

🌲Basic prettifier for Pino log lines
MIT License
1.27k stars 150 forks source link

How can I use pino-pretty as an log transformer in a pipeline? #539

Open ccll opened 3 weeks ago

ccll commented 3 weeks ago

I'd like TO use pino-pretty to convert JSON to human readable, then feed the result to my custom multi-stream. But it seems that pino-pretty directly output to stdout so my custom stream got nothing.

Am I missing the point of pino's stream based approach?

  pino(
        {
            transport: {
                pipeline: [
                    {
                        target: "pino-pretty",
                        options: {
                            colorize: true,
                        },
                    },
                ],
            },
        },
        pino.multistream([
            // { stream: process.stdout },
            {
                stream: {
                    write: (msg: string) => {
                        logFunc(msg);
                    },
                },
            },
        ]),
    );