pinojs / pino

🌲 super fast, all natural json logger
http://getpino.io
MIT License
14.1k stars 870 forks source link

Configuration ignored when multiple transport targets #1413

Open tasdflkjweio opened 2 years ago

tasdflkjweio commented 2 years ago

The formatter and timestamp are disregarded when using the following configuration:

const transports = pino.transport({
            targets: [
                {
            level: 'info',
            target: 'pino/file',
            options: { destination: `${logDir}/svc_info.log`, mkdir: true, }
            },
            {
                target: 'pino/file',
                options: { destination: `${logDir}/svc_error.log`, mkdir: true, }
            }
            ]
        });

const logger = pino({
    level: 'info',
    formatters: {
        level(label) { return { level: label }; },
    },
    timestamp: pino.stdTimeFunctions.isoTime
}, transports)

I still see the log level number (rather than label) and epoch time in ms. If I use just one of the transports (i.e., not the array syntax), it works as expected.

mcollina commented 2 years ago

Unfortunately we need levels to be a number for multistream to work. Essentially the level formatter is incompatible with transports. We need to throw a better error.

I would love to have some code that implements it, however I do not think it's possible.

tasdflkjweio commented 2 years ago

Is there another way to achieve this same result?

maidul98 commented 10 months ago

Ran into the same thing. Is there a way to add level as string when using multiple transports? Also why is it not possible?

quallrum commented 7 months ago

Same here, are there any updates on this?

vmpino commented 4 months ago

Similar behavior in v9, but instead of ignoring configuration options, both of the transports just fail. Only using one transport in the targets array or removing the log level formatter bypasses this. The latter is doable but not ideal.

DomiiBunn commented 3 months ago

This is a geniuane issue that is causing a bit of frustration especially that the failure is silent....

Even without a custom formatter the issue ocurs