all files / pnr-common/lib/node/logging/ syslog-logger.js

100% Statements 7/7
50% Branches 2/4
100% Functions 0/0
100% Lines 6/6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35                                                         
'use strict';
 
const winston = require( 'winston' );
require('local_winston-syslog').Syslog; //jshint ignore: line
 
winston.setLevels(winston.config.syslog.levels );
 
exports.syslogTransport = (config, custom) =>
   new winston.transports.Syslog( Object.assign({
      host: config.networking.syslog_host,
      port: config.networking.syslog_port,
      //need to add the 4 for the protocol to match what winston is expecting
      //see https://github.com/winstonjs/winston-syslog/blob/master/README.md
      protocol: config.networking.syslog_protocol === 'tcp' ? 'tcp4':
                config.networking.syslog_protocol === 'udp' ? 'udp4':
                config.networking.syslog_protocol,
      eol: '\n',
      localhost: '', //set this so it does not print 'localhost' in log output
      appName: 'MSIP',
      facility: 'local0',
      pid: '0', //do not want to output process id in customer logs
      level: 'info',
      colorize: false,
      timestamp: false,
      showLevel: false,
      handleExceptions: true
   }, custom));
 
exports.syslog = (config, custom) => new( winston.Logger )( {
         transports: [
            exports.syslogTransport(config, custom)
         ],
         exitOnError: false
} );