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