'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
} );
|