Winston Log-Levels - how to use the same transporter for all levels?


#1

Hi guys,

Winston experts - I need your help:

I am playing around with winston as my Logging-Framework
and having problems getting the output-order configured correctly.

I’d like to keep it simple and send ALL log-levels to console,
BUT winston somehow MESSES up the order.

Note how the console-output order (in the screenshot)
differes from the code-lines:

  var logLevels = {
    levels: {
      debug: 0,
      info: 1,
      warn: 2,
      error: 3,
      cricitcal: 4,
    },
    colors: {
      debug: 'white',
      info: 'white',
      warn: 'white',
      error: 'red',
      cricitcal: 'red',
    }
  };
  Logger = new (Winston.Logger) ({ 
    levels: logLevels.levels,
    colors: logLevels.colors,
    transports: [
      new (Winston.transports.Console)({
        stderrLevels: ['error', 'critical',], // send all to stdout!
        colorize: true,
        level: 'debug',
      }),
    ],
  });

  // test
  Logger.debug('0 debug');
  Logger.info('1 info');
  Logger.warn('2 warn');
  Logger.error('3 error');
  Logger.cricitcal('4 cricitcal');

  Logger.debug('0 debug');
  Logger.cricitcal('4 cricitcal');