spee.ch/config/slackConfig.js

35 lines
1.1 KiB
JavaScript
Raw Normal View History

const { logging } = require('./speechConfig.js');
const { slackWebHook, slackErrorChannel, slackInfoChannel } = logging;
const winstonSlackWebHook = require('winston-slack-webhook').SlackWebHook;
module.exports = (winston) => {
if (slackWebHook) {
2017-11-07 00:18:45 +01:00
// add a transport for errors to slack
if (slackErrorChannel) {
2017-12-08 19:25:05 +01:00
winston.add(winstonSlackWebHook, {
name : 'slack-errors-transport',
level : 'warn',
webhookUrl: slackWebHook,
channel : slackErrorChannel,
2017-12-08 19:25:05 +01:00
username : 'spee.ch',
iconEmoji : ':face_with_head_bandage:',
});
};
if (slackInfoChannel) {
2017-12-08 19:25:05 +01:00
winston.add(winstonSlackWebHook, {
name : 'slack-info-transport',
level : 'info',
webhookUrl: slackWebHook,
channel : slackInfoChannel,
2017-12-08 19:25:05 +01:00
username : 'spee.ch',
iconEmoji : ':nerd_face:',
});
};
2017-11-07 00:18:45 +01:00
// send test message
winston.error('Slack "error" logging is online.');
winston.info('Slack "info" logging is online.');
2017-09-25 17:49:28 +02:00
} else {
2017-12-08 19:25:05 +01:00
winston.warn('Slack logging is not enabled because no slackWebHook config var provided.');
2017-09-25 17:49:28 +02:00
}
};