The @aliceo2/web-ui framework offers 2 independent modules:
Logger module:Which features:
InfoLogger server (if InfoLogger package is installed under /opt/o2-InfoLogger/)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
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:
FILE_NAME] - path to file where logs will be written;FILE_LVL] - log severity of logs written to file; (default: warn);CONSOLE_LVL] - log severity of logs written to console; (default: debug)CONSOLE_SYSTEMD] - flags, console logs will be converted to a format more convenient for journalctl (where logs are stored from systemd services);LABEL] - label to use as prefix for all log messages (default empty);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:
host - InfoLogger server hostport - InfoLogger server port