spee.ch/config/slackLoggerConfig.js

28 lines
948 B
JavaScript
Raw Normal View History

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');
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',
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',
iconEmoji : ':nerd_face:',
});
// send test message
winston.error('Testing slack logging... slack logging is online.');
};