WebUi

Backend - Logging module

The @aliceo2/web-ui framework offers 2 independent modules:

Logger module:

Which features:

Import module and use default instance

The default instance will be printing logs to the console colored based on their level; Moreover, it will prefix all logs with timestamp and label provided to the constructor

const {LogManager} = require('@aliceo2/web-ui');
const logger = LogManager.getLogger('my-app');
logger.debug('Created default instance of console logger');

Which will result in:

1970-01-01T01:01:01.000Z [my-app] debug: Created default instance of console logger

Import module and configure

Configuring logger is optional and required only when non default behavior of logger is desired such as:

const {LogManager} = require('@aliceo2/web-ui');
LogManager.configure({
  winston: {
    file: {
      name: FILE_NAME, 
      level: FILE_LVL,
    }, 
    console: {
      level: CONSOLE_LVL,
      systemD: CONSOLE_SYSTEMD,
    }
  },
  infologger: true
});
LogManager.getLogger(LABEL);

Where:

InfoLogger Receiver

Module to be used to receive logs from InfoLogger Server endpoint

const {InfoLoggerReceiver} = require('@aliceo2/web-ui');
const ilg = new InfoLoggerReceiver(config);

Where config is a JSON object with following fields expected: