pinojs / pino

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

Log level doesn't seem to apply when `multistream` object is passed as a second argument #1468

Closed lambdagg closed 2 years ago

lambdagg commented 2 years ago

Hi there. I've been using Pino for a few days now, but I just saw that my trace and debug logs were not getting printed out.

I tried this:

import pino from 'pino';
import { createWriteStream } from 'fs';

const logger = pino(
    { name: 'app', level: 'trace' },
    pino.multistream([
        process.stdout,
        createWriteStream('../logs/app.log', { flags: 'a' }),
    ]),
);

console.log(logger.level);
console.log(logger.isLevelEnabled('debug'));
console.log(logger.isLevelEnabled('trace'));

logger.debug('Debug');
logger.trace('Trace');
logger.info('Info');

which outputs me trace, then true, true and skips to the 'Info' part (as a JSON object) but nothing more.

But if I try commenting out the whole block as following:

    // pino.multistream([
    //     process.stdout,
    //     createWriteStream('../logs/app.log', { flags: 'a' }),
    // ]),

, then everything works as intended.

I've been googling stuff for a few hours now, no chance. I'm not sure if I did something wrong or if it is just a bug.

Thank you!

jsumners commented 2 years ago

https://getpino.io/#/docs/api?id=pinomultistreamstreamsarray-opts-gt-multistreamres

mcollina commented 2 years ago

You need to specify the level for each substream of multistream.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.