2017-09-14 00:41:52 +02:00
|
|
|
const config = require('config');
|
|
|
|
const SLACK_WEB_HOOK = config.get('Logging.SlackWebHook');
|
2017-09-14 22:09:09 +02:00
|
|
|
const SLACK_ERROR_CHANNEL = config.get('Logging.SlackErrorChannel');
|
2017-09-14 22:13:26 +02:00
|
|
|
const SLACK_INFO_CHANNEL = config.get('Logging.SlackInfoChannel');
|
2017-09-14 00:41:52 +02:00
|
|
|
const winstonSlackWebHook = require('winston-slack-webhook').SlackWebHook;
|
|
|
|
|
|
|
|
module.exports = (winston) => {
|
|
|
|
// add a transport for errors
|
|
|
|
winston.add(winstonSlackWebHook, {
|
|
|
|
name : 'slack-errors-transport',
|
|
|
|
level : 'error',
|
|
|
|
webhookUrl: SLACK_WEB_HOOK,
|
2017-09-14 22:09:09 +02:00
|
|
|
channel : SLACK_ERROR_CHANNEL,
|
2017-09-15 01:17:49 +02:00
|
|
|
username : 'spee.ch',
|
2017-09-14 00:41:52 +02:00
|
|
|
iconEmoji : ':face_with_head_bandage:',
|
|
|
|
});
|
|
|
|
winston.add(winstonSlackWebHook, {
|
|
|
|
name : 'slack-info-transport',
|
|
|
|
level : 'info',
|
|
|
|
webhookUrl: SLACK_WEB_HOOK,
|
2017-09-14 22:09:09 +02:00
|
|
|
channel : SLACK_INFO_CHANNEL,
|
2017-09-15 01:17:49 +02:00
|
|
|
username : 'spee.ch',
|
2017-09-14 00:41:52 +02:00
|
|
|
iconEmoji : ':nerd_face:',
|
|
|
|
});
|
|
|
|
// send test message
|
|
|
|
winston.error('Testing slack logging... slack logging is online.');
|
|
|
|
};
|