pinojs / pino-pretty

🌲Basic prettifier for Pino log lines
MIT License
1.25k stars 147 forks source link

Not displaying trace logs despite minimum trace level #455

Open tjakubo opened 1 year ago

tjakubo commented 1 year ago

This MWE

const pino = require('pino');

const transport = pino.transport({
  targets: [
    {
      level: 'trace',
      target: 'pino-pretty',
      options: {},
    },
  ],
});

const log = pino({}, transport);

console.log('console.log');
log.info('pino.info');
log.trace('pino.trace');

Only outputs two lines instead of expected three. Is it some misconfiguration issue, why doesn't it also show the trace log? The docs suggest that "level" property is a minimum inclusive level.

Output from provided example image

EDIT: Also, some details, the empty line in my output is not from log.trace, and when using a file transport

{
    level: 'trace',
    target: 'pino/file',
    options: {
      destination: `./pino.log`,
    },
},

it does include the trace line in pino.log file.

jsumners commented 1 year ago

Possibly there is a bug?

const pino = require('pino');
const log = pino({});

log.info('pino.info');
log.trace('pino.trace');
log.warn('pino.warn')
❯ node index.js|./node_modules/.bin/pino-pretty -L trace
[08:43:34.781] INFO (12635): pino.info
[08:43:34.781] WARN (12635): pino.warn

Would you like to send a Pull Request to address this issue? Remember to add unit tests.

jmjf commented 1 year ago

Is this a pino configuration issue?

const pino = require('pino');

const transport = pino.transport({
  targets: [
    {
      level: 'trace',
      target: 'pino-pretty',
    },
        {
            level: 'trace',
            target: 'pino/file',
            destination: 1,
        }
  ],
});

const log1 = pino({}, transport);

log1.fatal('log1.fatal');
log1.error('log1.error');
log1.warn('log1.warn');
log1.info('log1.info');
log1.debug('log1.debug');
log1.trace('log1.trace');

const log2 = pino({level: 'trace'}, transport);

log2.fatal('log2.fatal');
log2.error('log2.error');
log2.warn('log2.warn');
log2.info('log2.info');
log2.debug('log2.debug');
log2.trace('log2.trace');

Output may be a bit messy, but log1 stops at INFO for both transports while log2 goes all the way to TRACE.

EDIT: Removing level from the transports also stops an INFO. The point being, pino configuration and pino-pretty configuration are different. You must set both to the same level, it seems.

AndreasGalster2 commented 11 months ago

Is this a pino configuration issue?

const pino = require('pino');

const transport = pino.transport({
  targets: [
    {
      level: 'trace',
      target: 'pino-pretty',
    },
      {
          level: 'trace',
          target: 'pino/file',
          destination: 1,
      }
  ],
});

const log1 = pino({}, transport);

log1.fatal('log1.fatal');
log1.error('log1.error');
log1.warn('log1.warn');
log1.info('log1.info');
log1.debug('log1.debug');
log1.trace('log1.trace');

const log2 = pino({level: 'trace'}, transport);

log2.fatal('log2.fatal');
log2.error('log2.error');
log2.warn('log2.warn');
log2.info('log2.info');
log2.debug('log2.debug');
log2.trace('log2.trace');

Output may be a bit messy, but log1 stops at INFO for both transports while log2 goes all the way to TRACE.

EDIT: Removing level from the transports also stops an INFO. The point being, pino configuration and pino-pretty configuration are different. You must set both to the same level, it seems.

This worked for me, but I just noticed it doesn't work once you set a customLevel in your transport / log2 config.

jmjf commented 11 months ago

You have to tell pino-pretty about the custom level. From the command line, -x; programmatically, the customLevels option, per the config docs in the readme.

On Mon, Nov 13, 2023, 08:12 AndreasGalster2 @.***> wrote:

Is this a pino configuration issue?

const pino = require('pino'); const transport = pino.transport({ targets: [ { level: 'trace', target: 'pino-pretty', }, { level: 'trace', target: 'pino/file', destination: 1, } ],}); const log1 = pino({}, transport); log1.fatal('log1.fatal');log1.error('log1.error');log1.warn('log1.warn');log1.info('log1.info');log1.debug('log1.debug');log1.trace('log1.trace'); const log2 = pino({level: 'trace'}, transport); log2.fatal('log2.fatal');log2.error('log2.error');log2.warn('log2.warn');log2.info('log2.info');log2.debug('log2.debug');log2.trace('log2.trace');

Output may be a bit messy, but log1 stops at INFO for both transports while log2 goes all the way to TRACE.

EDIT: Removing level from the transports also stops an INFO. The point being, pino configuration and pino-pretty configuration are different. You must set both to the same level, it seems.

This worked for me, but I just noticed it doesn't work once you set a customLevel in your transport / log2 config.

— Reply to this email directly, view it on GitHub https://github.com/pinojs/pino-pretty/issues/455#issuecomment-1808141615, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASIV674R4S6EJQ6WHBHPFTYEIMFNAVCNFSM6AAAAAA4NQ6QYWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBYGE2DCNRRGU . You are receiving this because you commented.Message ID: @.***>